fix (tracker-assist): 3.5.2: resume action-control on a new page
This commit is contained in:
parent
5b84ada809
commit
33e000efc6
4 changed files with 33 additions and 14 deletions
2
tracker/tracker-assist/package-lock.json
generated
2
tracker/tracker-assist/package-lock.json
generated
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@openreplay/tracker-assist",
|
||||
"version": "3.5.0",
|
||||
"version": "3.5.1-beta.1",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@openreplay/tracker-assist",
|
||||
"description": "Tracker plugin for screen assistance through the WebRTC",
|
||||
"version": "3.5.0",
|
||||
"version": "3.5.2",
|
||||
"keywords": [
|
||||
"WebRTC",
|
||||
"assistance",
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ export interface Options {
|
|||
onAgentConnect: () => ((()=>{}) | void),
|
||||
onCallStart: () => ((()=>{}) | void),
|
||||
session_calling_peer_key: string,
|
||||
session_control_peer_key: string,
|
||||
callConfirm: ConfirmOptions,
|
||||
controlConfirm: ConfirmOptions,
|
||||
|
||||
|
|
@ -58,6 +59,7 @@ export default class Assist {
|
|||
) {
|
||||
this.options = Object.assign({
|
||||
session_calling_peer_key: "__openreplay_calling_peer",
|
||||
session_control_peer_key: "__openreplay_control_peer",
|
||||
config: null,
|
||||
onCallStart: ()=>{},
|
||||
onAgentConnect: ()=>{},
|
||||
|
|
@ -103,7 +105,8 @@ export default class Assist {
|
|||
"peerId": peerID,
|
||||
"identity": "session",
|
||||
"sessionInfo": JSON.stringify(this.app.getSessionInfo()),
|
||||
}
|
||||
},
|
||||
transports: ["websocket"],
|
||||
})
|
||||
socket.onAny((...args) => app.debug.log("Socket:", ...args))
|
||||
|
||||
|
|
@ -125,37 +128,53 @@ export default class Assist {
|
|||
this.assistDemandedRestart = true
|
||||
this.app.stop();
|
||||
this.app.start().then(() => { this.assistDemandedRestart = false })
|
||||
const storedControllingAgent = sessionStorage.getItem(this.options.session_control_peer_key)
|
||||
if (storedControllingAgent !== null && ids.includes(storedControllingAgent)) {
|
||||
grantControl(storedControllingAgent)
|
||||
socket.emit("control_granted", storedControllingAgent)
|
||||
} else {
|
||||
sessionStorage.removeItem(this.options.session_control_peer_key)
|
||||
}
|
||||
})
|
||||
|
||||
let confirmRC: ConfirmWindow | null = null
|
||||
const mouse = new Mouse() // TODO: lazy init
|
||||
let controllingAgent: string | null = null
|
||||
function releaseControl() {
|
||||
confirmRC?.remove()
|
||||
mouse.remove()
|
||||
controllingAgent = null
|
||||
}
|
||||
socket.on("request_control", (id: string) => {
|
||||
const requestControl = (id: string) => {
|
||||
if (controllingAgent !== null) {
|
||||
socket.emit("control_rejected", id)
|
||||
return
|
||||
}
|
||||
controllingAgent = id
|
||||
controllingAgent = id // TODO: more explicit pending state
|
||||
confirmRC = new ConfirmWindow(controlConfirmDefault(this.options.controlConfirm))
|
||||
confirmRC.mount().then(allowed => {
|
||||
if (allowed) { // TODO: per agent id
|
||||
mouse.mount()
|
||||
if (allowed) {
|
||||
grantControl(id)
|
||||
socket.emit("control_granted", id)
|
||||
} else {
|
||||
releaseControl()
|
||||
socket.emit("control_rejected", id)
|
||||
}
|
||||
}).catch()
|
||||
})
|
||||
}
|
||||
const grantControl = (id: string) => {
|
||||
controllingAgent = id
|
||||
mouse.mount()
|
||||
sessionStorage.setItem(this.options.session_control_peer_key, id)
|
||||
}
|
||||
const releaseControl = () => {
|
||||
confirmRC?.remove()
|
||||
mouse.remove()
|
||||
controllingAgent = null
|
||||
sessionStorage.removeItem(this.options.session_control_peer_key)
|
||||
}
|
||||
socket.on("request_control", requestControl)
|
||||
socket.on("release_control", (id: string) => {
|
||||
if (controllingAgent !== id) { return }
|
||||
releaseControl()
|
||||
})
|
||||
|
||||
|
||||
socket.on("scroll", (id, d) => { id === controllingAgent && mouse.scroll(d) })
|
||||
socket.on("click", (id, xy) => { id === controllingAgent && mouse.click(xy) })
|
||||
socket.on("move", (id, xy) => { id === controllingAgent && mouse.move(xy) })
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
"alwaysStrict": true,
|
||||
"target": "es6",
|
||||
"module": "es6",
|
||||
"moduleResolution": "nodenext",
|
||||
"moduleResolution": "node",
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"declaration": true,
|
||||
"outDir": "./lib"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue