feat (tracker-assist): 3.5.3:onRemoteControlStart

This commit is contained in:
ShiKhu 2022-02-27 21:56:00 +01:00
parent 33e000efc6
commit 172f5c5211
2 changed files with 11 additions and 3 deletions

View file

@ -1,7 +1,7 @@
{
"name": "@openreplay/tracker-assist",
"description": "Tracker plugin for screen assistance through the WebRTC",
"version": "3.5.2",
"version": "3.5.3",
"keywords": [
"WebRTC",
"assistance",

View file

@ -14,9 +14,12 @@ import type { Options as ConfirmOptions } from './ConfirmWindow.js';
//@ts-ignore peerjs hack for webpack5 (?!) TODO: ES/node modules;
Peer = Peer.default || Peer;
type BehinEndCallback = () => ((()=>{}) | void)
export interface Options {
onAgentConnect: () => ((()=>{}) | void),
onCallStart: () => ((()=>{}) | void),
onAgentConnect: BehinEndCallback,
onCallStart: BehinEndCallback,
onRemoteControlStart: BehinEndCallback,
session_calling_peer_key: string,
session_control_peer_key: string,
callConfirm: ConfirmOptions,
@ -63,6 +66,7 @@ export default class Assist {
config: null,
onCallStart: ()=>{},
onAgentConnect: ()=>{},
onRemoteControlStart: ()=>{},
callConfirm: {},
controlConfirm: {}, // TODO: clear options passing/merging/overriting
},
@ -157,12 +161,16 @@ export default class Assist {
}
}).catch()
}
let onRemoteControlStop: (()=>void) | null = null
const grantControl = (id: string) => {
controllingAgent = id
mouse.mount()
onRemoteControlStop = this.options.onRemoteControlStart() || null
sessionStorage.setItem(this.options.session_control_peer_key, id)
}
const releaseControl = () => {
typeof onRemoteControlStop === 'function' && onRemoteControlStop()
onRemoteControlStop = null
confirmRC?.remove()
mouse.remove()
controllingAgent = null