implement relative path for connect assist v2 (#761)
This commit is contained in:
parent
72b7a9c869
commit
5ad34c024a
2 changed files with 30 additions and 17 deletions
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@openreplay/tracker-assist",
|
||||
"description": "Tracker plugin for screen assistance through the WebRTC",
|
||||
"version": "4.1.1",
|
||||
"version": "4.1.2",
|
||||
"keywords": [
|
||||
"WebRTC",
|
||||
"assistance",
|
||||
|
|
|
|||
|
|
@ -18,21 +18,22 @@ import type { Options as ConfirmOptions, } from './ConfirmWindow/defaults.js'
|
|||
type StartEndCallback = () => ((()=>Record<string, unknown>) | void)
|
||||
|
||||
export interface Options {
|
||||
onAgentConnect: StartEndCallback,
|
||||
onCallStart: StartEndCallback,
|
||||
onRemoteControlStart: StartEndCallback,
|
||||
session_calling_peer_key: string,
|
||||
session_control_peer_key: string,
|
||||
callConfirm: ConfirmOptions,
|
||||
controlConfirm: ConfirmOptions,
|
||||
onAgentConnect: StartEndCallback;
|
||||
onCallStart: StartEndCallback;
|
||||
onRemoteControlStart: StartEndCallback;
|
||||
session_calling_peer_key: string;
|
||||
session_control_peer_key: string;
|
||||
callConfirm: ConfirmOptions;
|
||||
controlConfirm: ConfirmOptions;
|
||||
|
||||
// @depricated
|
||||
confirmText?: string,
|
||||
confirmText?: string;
|
||||
// @depricated
|
||||
confirmStyle?: Properties,
|
||||
confirmStyle?: Properties;
|
||||
|
||||
config: RTCConfiguration,
|
||||
callUITemplate?: string,
|
||||
config: RTCConfiguration;
|
||||
serverURL: string
|
||||
callUITemplate?: string;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -72,6 +73,7 @@ export default class Assist {
|
|||
session_calling_peer_key: '__openreplay_calling_peer',
|
||||
session_control_peer_key: '__openreplay_control_peer',
|
||||
config: null,
|
||||
serverURL: null,
|
||||
onCallStart: ()=>{},
|
||||
onAgentConnect: ()=>{},
|
||||
onRemoteControlStart: ()=>{},
|
||||
|
|
@ -126,7 +128,18 @@ export default class Assist {
|
|||
private readonly setCallingState = (newState: CallingState): void => {
|
||||
this.callingState = newState
|
||||
}
|
||||
|
||||
private getHost():string{
|
||||
if (this.options.serverURL){
|
||||
return new URL(this.options.serverURL).host
|
||||
}
|
||||
return this.app.getHost()
|
||||
}
|
||||
private getBasePrefixUrl(): string{
|
||||
if (this.options.serverURL){
|
||||
return new URL(this.options.serverURL).pathname
|
||||
}
|
||||
return ''
|
||||
}
|
||||
private onStart() {
|
||||
const app = this.app
|
||||
const sessionId = app.getSessionID()
|
||||
|
|
@ -136,8 +149,8 @@ export default class Assist {
|
|||
const peerID = `${app.getProjectKey()}-${sessionId}`
|
||||
|
||||
// SocketIO
|
||||
const socket = this.socket = connect(app.getHost(), {
|
||||
path: '/ws-assist/socket',
|
||||
const socket = this.socket = connect(this.getHost(), {
|
||||
path: this.getBasePrefixUrl()+'/ws-assist/socket',
|
||||
query: {
|
||||
'peerId': peerID,
|
||||
'identity': 'session',
|
||||
|
|
@ -269,8 +282,8 @@ export default class Assist {
|
|||
|
||||
// PeerJS call (todo: use native WebRTC)
|
||||
const peerOptions = {
|
||||
host: app.getHost(),
|
||||
path: '/assist',
|
||||
host: this.getHost(),
|
||||
path: this.getBasePrefixUrl()+'/assist',
|
||||
port: location.protocol === 'http:' && this.noSecureMode ? 80 : 443,
|
||||
//debug: appOptions.__debug_log ? 2 : 0, // 0 Print nothing //1 Prints only errors. / 2 Prints errors and warnings. / 3 Prints all logs.
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue