@signalwire/js
Advanced tools
Comparing version 1.3.0-alpha.1 to 1.3.0-alpha.2
@@ -6,2 +6,11 @@ # Changelog | ||
## [Unreleased] | ||
### Removed | ||
- Remove deprecated getters: `devices`, `videoDevices`, `audioInDevices`, `audioOutDevices`. | ||
- Remove deprecated `refreshDevices()` method. Use `getDevices()` instead. | ||
## [1.2.7] - 2020-02-21 | ||
### Fixed | ||
- Remove default values for `googleMaxBitrate`, `googleMinBitrate` and `googleStartBitrate`. | ||
## [1.2.6] - 2020-02-06 | ||
@@ -8,0 +17,0 @@ ### Added |
@@ -18,2 +18,3 @@ import * as log from 'loglevel'; | ||
contexts: string[]; | ||
timeoutErrorCode: number; | ||
protected connection: Connection; | ||
@@ -24,3 +25,2 @@ protected _jwtAuth: boolean; | ||
protected _reconnectTimeout: any; | ||
protected _reconnectDelay: number; | ||
protected _autoReconnect: boolean; | ||
@@ -34,2 +34,3 @@ protected _idle: boolean; | ||
get expired(): boolean; | ||
get reconnectDelay(): number; | ||
execute(msg: BaseMessage): any; | ||
@@ -36,0 +37,0 @@ executeRaw(text: string): void; |
@@ -17,5 +17,5 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
import { ADD, REMOVE, SwEvent, BladeMethod } from './util/constants'; | ||
import { NOTIFICATION_TYPE } from './webrtc/constants'; | ||
import { Notification } from './webrtc/constants'; | ||
import { Subscription, Connect, Reauthenticate, Ping } from './messages/Blade'; | ||
import { isFunction } from './util/helpers'; | ||
import { isFunction, randomInt } from './util/helpers'; | ||
import { sessionStorage } from './util/storage/'; | ||
@@ -33,6 +33,6 @@ const KEEPALIVE_INTERVAL = 10 * 1000; | ||
this.contexts = []; | ||
this.timeoutErrorCode = -32000; | ||
this.connection = null; | ||
this._jwtAuth = false; | ||
this._doKeepAlive = false; | ||
this._reconnectDelay = 5000; | ||
this._autoReconnect = true; | ||
@@ -61,2 +61,5 @@ this._idle = false; | ||
} | ||
get reconnectDelay() { | ||
return randomInt(6, 2) * 1000; | ||
} | ||
execute(msg) { | ||
@@ -72,3 +75,9 @@ if (this._idle) { | ||
} | ||
return this.connection.send(msg); | ||
return this.connection.send(msg) | ||
.catch(error => { | ||
if (error.code && error.code === this.timeoutErrorCode) { | ||
this._closeConnection(); | ||
} | ||
throw error; | ||
}); | ||
} | ||
@@ -157,3 +166,2 @@ executeRaw(text) { | ||
_handleLoginError(error) { | ||
this._autoReconnect = false; | ||
trigger(SwEvent.Error, error, this.uuid); | ||
@@ -202,3 +210,3 @@ } | ||
if (this._autoReconnect) { | ||
this._reconnectTimeout = setTimeout(() => this.connect(), this._reconnectDelay); | ||
this._reconnectTimeout = setTimeout(() => this.connect(), this.reconnectDelay); | ||
} | ||
@@ -287,3 +295,3 @@ } | ||
logger.warn('Your JWT is going to expire. You should refresh it to keep the session live.'); | ||
trigger(SwEvent.Notification, { type: NOTIFICATION_TYPE.refreshToken, session: this }, this.uuid, false); | ||
trigger(SwEvent.Notification, { type: Notification.RefreshToken, session: this }, this.uuid, false); | ||
} | ||
@@ -290,0 +298,0 @@ if (!this.expired) { |
import BaseSession from './BaseSession'; | ||
import { ICacheDevices, IAudioSettings, IVideoSettings, BroadcastParams, SubscribeParams } from './util/interfaces'; | ||
import { IWebRTCCall } from './webrtc/interfaces'; | ||
import { IAudioSettings, IVideoSettings, BroadcastParams, SubscribeParams } from './util/interfaces'; | ||
import BaseMessage from './messages/BaseMessage'; | ||
import WebRTCCall from './webrtc/WebRTCCall'; | ||
export default abstract class BrowserSession extends BaseSession { | ||
calls: { | ||
[callId: string]: IWebRTCCall; | ||
[callId: string]: WebRTCCall; | ||
}; | ||
@@ -13,2 +14,3 @@ micId: string; | ||
autoRecoverCalls: boolean; | ||
incognito: boolean; | ||
private _iceServers; | ||
@@ -18,10 +20,8 @@ private _localElement; | ||
protected _jwtAuth: boolean; | ||
protected _reconnectDelay: number; | ||
protected _devices: ICacheDevices; | ||
protected _audioConstraints: boolean | MediaTrackConstraints; | ||
protected _videoConstraints: boolean | MediaTrackConstraints; | ||
protected _speaker: string; | ||
get reconnectDelay(): number; | ||
connect(): Promise<void>; | ||
checkPermissions(audio?: boolean, video?: boolean): Promise<boolean>; | ||
logout(): void; | ||
disconnect(): Promise<void>; | ||
@@ -34,14 +34,3 @@ speedTest(bytes: number): Promise<unknown>; | ||
validateDeviceId(id: string, label: string, kind: MediaDeviceInfo['kind']): Promise<string>; | ||
refreshDevices(): Promise<ICacheDevices>; | ||
get devices(): ICacheDevices; | ||
getDeviceResolutions(deviceId: string): Promise<any[]>; | ||
get videoDevices(): { | ||
[deviceId: string]: MediaDeviceInfo; | ||
}; | ||
get audioInDevices(): { | ||
[deviceId: string]: MediaDeviceInfo; | ||
}; | ||
get audioOutDevices(): { | ||
[deviceId: string]: MediaDeviceInfo; | ||
}; | ||
get mediaConstraints(): { | ||
@@ -65,5 +54,7 @@ audio: boolean | MediaTrackConstraints; | ||
get remoteElement(): HTMLMediaElement | string | Function; | ||
vertoBroadcast({ nodeId, channel: eventChannel, data }: BroadcastParams): void; | ||
vertoSubscribe({ nodeId, channels: eventChannel, handler }: SubscribeParams): Promise<any>; | ||
vertoUnsubscribe({ nodeId, channels: eventChannel }: SubscribeParams): Promise<any>; | ||
vertoBroadcast({ nodeId, channel, data }: BroadcastParams): any; | ||
vertoSubscribe({ nodeId, channels, handler }: SubscribeParams): Promise<any>; | ||
vertoUnsubscribe({ nodeId, channels }: SubscribeParams): any; | ||
_wrapInExecute(message: BaseMessage): BaseMessage; | ||
execute(message: BaseMessage): any; | ||
} |
@@ -21,3 +21,2 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}; | ||
import logger from './util/logger'; | ||
import BaseSession from './BaseSession'; | ||
@@ -27,4 +26,6 @@ import { registerOnce, trigger } from './services/Handler'; | ||
import { State, DeviceType } from './webrtc/constants'; | ||
import { getDevices, scanResolutions, removeUnsupportedConstraints, checkDeviceIdConstraints, destructSubscribeResponse, getUserMedia, assureDeviceId } from './webrtc/helpers'; | ||
import { getDevices, scanResolutions, removeUnsupportedConstraints, checkDeviceIdConstraints, getUserMedia, assureDeviceId } from './webrtc/helpers'; | ||
import { findElementByType } from './util/helpers'; | ||
import BaseRequest from './messages/verto/BaseRequest'; | ||
import { Execute } from './messages/Blade'; | ||
import { Unsubscribe, Subscribe, Broadcast } from './messages/Verto'; | ||
@@ -38,2 +39,3 @@ import { localStorage } from './util/storage/'; | ||
this.autoRecoverCalls = true; | ||
this.incognito = false; | ||
this._iceServers = []; | ||
@@ -43,4 +45,2 @@ this._localElement = null; | ||
this._jwtAuth = true; | ||
this._reconnectDelay = 1000; | ||
this._devices = {}; | ||
this._audioConstraints = true; | ||
@@ -50,2 +50,5 @@ this._videoConstraints = false; | ||
} | ||
get reconnectDelay() { | ||
return 1000; | ||
} | ||
connect() { | ||
@@ -56,3 +59,5 @@ const _super = Object.create(null, { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this.sessionid = yield localStorage.getItem(SESSION_ID); | ||
if (!this.incognito) { | ||
this.sessionid = yield localStorage.getItem(SESSION_ID); | ||
} | ||
_super.connect.call(this); | ||
@@ -73,5 +78,2 @@ }); | ||
} | ||
logout() { | ||
this.disconnect(); | ||
} | ||
disconnect() { | ||
@@ -138,49 +140,5 @@ const _super = Object.create(null, { | ||
} | ||
refreshDevices() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
logger.warn('This method has been deprecated. Use getDevices() instead.'); | ||
const cache = {}; | ||
['videoinput', 'audioinput', 'audiooutput'].map((kind) => { | ||
cache[kind] = {}; | ||
Object.defineProperty(cache[kind], 'toArray', { | ||
value: function () { | ||
return Object.keys(this).map(k => this[k]); | ||
} | ||
}); | ||
}); | ||
const devices = yield this.getDevices(); | ||
devices.forEach((t) => { | ||
if (cache.hasOwnProperty(t.kind)) { | ||
cache[t.kind][t.deviceId] = t; | ||
} | ||
}); | ||
this._devices = cache; | ||
return this.devices; | ||
}); | ||
} | ||
get devices() { | ||
return this._devices || {}; | ||
} | ||
getDeviceResolutions(deviceId) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
return yield scanResolutions(deviceId); | ||
} | ||
catch (error) { | ||
throw error; | ||
} | ||
}); | ||
return scanResolutions(deviceId); | ||
} | ||
get videoDevices() { | ||
logger.warn('This property has been deprecated. Use getVideoDevices() instead.'); | ||
return this._devices.videoinput || {}; | ||
} | ||
get audioInDevices() { | ||
logger.warn('This property has been deprecated. Use getAudioInDevices() instead.'); | ||
return this._devices.audioinput || {}; | ||
} | ||
get audioOutDevices() { | ||
logger.warn('This property has been deprecated. Use getAudioOutDevices() instead.'); | ||
return this._devices.audiooutput || {}; | ||
} | ||
get mediaConstraints() { | ||
@@ -250,48 +208,38 @@ return { audio: this._audioConstraints, video: this._videoConstraints }; | ||
} | ||
vertoBroadcast({ nodeId, channel: eventChannel = '', data }) { | ||
if (!eventChannel) { | ||
throw new Error('Invalid channel for broadcast: ' + eventChannel); | ||
} | ||
const msg = new Broadcast({ sessid: this.sessionid, eventChannel, data }); | ||
vertoBroadcast({ nodeId, channel, data }) { | ||
const msg = new Broadcast({ sessid: this.sessionid, eventChannel: channel, data }); | ||
if (nodeId) { | ||
msg.targetNodeId = nodeId; | ||
} | ||
this.execute(msg).catch(error => error); | ||
return this.execute(msg); | ||
} | ||
vertoSubscribe({ nodeId, channels: eventChannel = [], handler }) { | ||
vertoSubscribe({ nodeId, channels, handler }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
eventChannel = eventChannel.filter(channel => channel && !this._existsSubscription(this.relayProtocol, channel)); | ||
if (!eventChannel.length) { | ||
return {}; | ||
} | ||
const msg = new Subscribe({ sessid: this.sessionid, eventChannel }); | ||
const msg = new Subscribe({ sessid: this.sessionid, eventChannel: channels }); | ||
if (nodeId) { | ||
msg.targetNodeId = nodeId; | ||
} | ||
const response = yield this.execute(msg); | ||
const { unauthorized = [], subscribed = [] } = destructSubscribeResponse(response); | ||
if (unauthorized.length) { | ||
unauthorized.forEach(channel => this._removeSubscription(this.relayProtocol, channel)); | ||
} | ||
subscribed.forEach(channel => this._addSubscription(this.relayProtocol, handler, channel)); | ||
return response; | ||
return this.execute(msg); | ||
}); | ||
} | ||
vertoUnsubscribe({ nodeId, channels: eventChannel = [] }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
eventChannel = eventChannel.filter(channel => channel && this._existsSubscription(this.relayProtocol, channel)); | ||
if (!eventChannel.length) { | ||
return {}; | ||
} | ||
const msg = new Unsubscribe({ sessid: this.sessionid, eventChannel }); | ||
if (nodeId) { | ||
msg.targetNodeId = nodeId; | ||
} | ||
const response = yield this.execute(msg); | ||
const { unsubscribed = [], notSubscribed = [] } = destructSubscribeResponse(response); | ||
unsubscribed.forEach(channel => this._removeSubscription(this.relayProtocol, channel)); | ||
notSubscribed.forEach(channel => this._removeSubscription(this.relayProtocol, channel)); | ||
return response; | ||
}); | ||
vertoUnsubscribe({ nodeId, channels }) { | ||
const msg = new Unsubscribe({ sessid: this.sessionid, eventChannel: channels }); | ||
if (nodeId) { | ||
msg.targetNodeId = nodeId; | ||
} | ||
return this.execute(msg); | ||
} | ||
_wrapInExecute(message) { | ||
const params = { | ||
message: message.request, | ||
node_id: message.targetNodeId || undefined | ||
}; | ||
return new Execute({ protocol: this.relayProtocol, method: 'message', params }); | ||
} | ||
execute(message) { | ||
if (message instanceof BaseRequest) { | ||
message = this._wrapInExecute(message); | ||
} | ||
return super.execute(message); | ||
} | ||
} |
@@ -12,5 +12,4 @@ import logger from '../util/logger'; | ||
if (event_type === 'webrtc.message') { | ||
const handler = new VertoHandler(session); | ||
handler.nodeId = node_id; | ||
handler.handleMessage(params.params); | ||
params.params.nodeId = node_id; | ||
VertoHandler(session, params.params); | ||
} | ||
@@ -17,0 +16,0 @@ else { |
@@ -16,3 +16,3 @@ import logger from '../util/logger'; | ||
}; | ||
const REQUEST_TIMEOUT = 10 * 1000; | ||
const TIMEOUT_MS = 10 * 1000; | ||
export default class Connection { | ||
@@ -98,5 +98,5 @@ constructor(session) { | ||
this._timers[id] = setTimeout(() => { | ||
trigger(id, { error: { code: '408', message: 'Request Timeout' } }); | ||
trigger(id, { error: { code: this.session.timeoutErrorCode, message: 'Timeout' } }); | ||
this._unsetTimer(id); | ||
}, REQUEST_TIMEOUT); | ||
}, TIMEOUT_MS); | ||
} | ||
@@ -103,0 +103,0 @@ _handleStringResponse(response) { |
@@ -1,8 +0,9 @@ | ||
declare const isQueued: (eventName: string, uniqueId?: string) => boolean; | ||
declare const queueLength: (eventName: string, uniqueId?: string) => number; | ||
declare const register: (eventName: string, callback: Function, uniqueId?: string) => void; | ||
declare const registerOnce: (eventName: string, callback: Function, uniqueId?: string) => void; | ||
declare const deRegister: (eventName: string, callback?: Function, uniqueId?: string) => boolean; | ||
declare const trigger: (eventName: string, data: any, uniqueId?: string, globalPropagation?: boolean) => boolean; | ||
declare const deRegisterAll: (eventName: string) => void; | ||
export { trigger, register, registerOnce, deRegister, deRegisterAll, isQueued, queueLength }; | ||
declare const isQueued: (event: string, uniqueId?: string) => boolean; | ||
declare const queueLength: (event: string, uniqueId?: string) => number; | ||
declare const register: (event: string, callback: Function, uniqueId?: string) => void; | ||
declare const registerOnce: (event: string, callback: Function, uniqueId?: string) => void; | ||
declare const deRegister: (event: string, callback?: Function, uniqueId?: string) => boolean; | ||
declare const trigger: (event: string, data: any, uniqueId?: string, globalPropagation?: boolean) => boolean; | ||
declare const deRegisterAll: (event: string) => void; | ||
declare const clearQueue: () => void; | ||
export { trigger, register, registerOnce, deRegister, deRegisterAll, isQueued, queueLength, clearQueue }; |
@@ -1,38 +0,39 @@ | ||
import { objEmpty, isFunction } from '../util/helpers'; | ||
import { isFunction } from '../util/helpers'; | ||
const GLOBAL = 'GLOBAL'; | ||
const queue = {}; | ||
const isQueued = (eventName, uniqueId = GLOBAL) => queue.hasOwnProperty(eventName) && queue[eventName].hasOwnProperty(uniqueId); | ||
const queueLength = (eventName, uniqueId = GLOBAL) => { | ||
if (!isQueued(eventName, uniqueId)) { | ||
return 0; | ||
} | ||
return queue[eventName][uniqueId].length; | ||
const _buildEventName = (event, uniqueId) => `${event}|${uniqueId}`; | ||
const isQueued = (event, uniqueId = GLOBAL) => { | ||
const eventName = _buildEventName(event, uniqueId); | ||
return eventName in queue; | ||
}; | ||
const register = (eventName, callback, uniqueId = GLOBAL) => { | ||
if (!queue.hasOwnProperty(eventName)) { | ||
queue[eventName] = {}; | ||
const queueLength = (event, uniqueId = GLOBAL) => { | ||
const eventName = _buildEventName(event, uniqueId); | ||
return eventName in queue ? queue[eventName].length : 0; | ||
}; | ||
const register = (event, callback, uniqueId = GLOBAL) => { | ||
const eventName = _buildEventName(event, uniqueId); | ||
if (!(eventName in queue)) { | ||
queue[eventName] = []; | ||
} | ||
if (!queue[eventName].hasOwnProperty(uniqueId)) { | ||
queue[eventName][uniqueId] = []; | ||
} | ||
queue[eventName][uniqueId].push(callback); | ||
queue[eventName].push(callback); | ||
}; | ||
const registerOnce = (eventName, callback, uniqueId = GLOBAL) => { | ||
const registerOnce = (event, callback, uniqueId = GLOBAL) => { | ||
const cb = function (data) { | ||
deRegister(eventName, cb, uniqueId); | ||
deRegister(event, cb, uniqueId); | ||
callback(data); | ||
}; | ||
cb.prototype.targetRef = callback; | ||
return register(eventName, cb, uniqueId); | ||
return register(event, cb, uniqueId); | ||
}; | ||
const deRegister = (eventName, callback, uniqueId = GLOBAL) => { | ||
if (!isQueued(eventName, uniqueId)) { | ||
const deRegister = (event, callback, uniqueId = GLOBAL) => { | ||
if (!isQueued(event, uniqueId)) { | ||
return false; | ||
} | ||
const eventName = _buildEventName(event, uniqueId); | ||
if (isFunction(callback)) { | ||
const len = queue[eventName][uniqueId].length; | ||
const len = queue[eventName].length; | ||
for (let i = len - 1; i >= 0; i--) { | ||
const fn = queue[eventName][uniqueId][i]; | ||
const fn = queue[eventName][i]; | ||
if (callback === fn || (fn.prototype && callback === fn.prototype.targetRef)) { | ||
queue[eventName][uniqueId].splice(i, 1); | ||
queue[eventName].splice(i, 1); | ||
} | ||
@@ -42,24 +43,22 @@ } | ||
else { | ||
queue[eventName][uniqueId] = []; | ||
queue[eventName] = []; | ||
} | ||
if (queue[eventName][uniqueId].length === 0) { | ||
delete queue[eventName][uniqueId]; | ||
if (objEmpty(queue[eventName])) { | ||
delete queue[eventName]; | ||
} | ||
if (queue[eventName].length === 0) { | ||
delete queue[eventName]; | ||
} | ||
return true; | ||
}; | ||
const trigger = (eventName, data, uniqueId = GLOBAL, globalPropagation = true) => { | ||
const trigger = (event, data, uniqueId = GLOBAL, globalPropagation = true) => { | ||
const _propagate = globalPropagation && uniqueId !== GLOBAL; | ||
if (!isQueued(eventName, uniqueId)) { | ||
if (!isQueued(event, uniqueId)) { | ||
if (_propagate) { | ||
trigger(eventName, data); | ||
trigger(event, data); | ||
} | ||
return false; | ||
} | ||
const len = queue[eventName][uniqueId].length; | ||
const eventName = _buildEventName(event, uniqueId); | ||
const len = queue[eventName].length; | ||
if (!len) { | ||
if (_propagate) { | ||
trigger(eventName, data); | ||
trigger(event, data); | ||
} | ||
@@ -69,12 +68,16 @@ return false; | ||
for (let i = len - 1; i >= 0; i--) { | ||
queue[eventName][uniqueId][i](data); | ||
queue[eventName][i](data); | ||
} | ||
if (_propagate) { | ||
trigger(eventName, data); | ||
trigger(event, data); | ||
} | ||
return true; | ||
}; | ||
const deRegisterAll = (eventName) => { | ||
delete queue[eventName]; | ||
const deRegisterAll = (event) => { | ||
const eventName = _buildEventName(event, ''); | ||
Object.keys(queue) | ||
.filter(name => name.indexOf(eventName) === 0) | ||
.forEach(event => delete queue[event]); | ||
}; | ||
export { trigger, register, registerOnce, deRegister, deRegisterAll, isQueued, queueLength }; | ||
const clearQueue = () => Object.keys(queue).forEach(event => delete queue[event]); | ||
export { trigger, register, registerOnce, deRegister, deRegisterAll, isQueued, queueLength, clearQueue }; |
@@ -20,1 +20,3 @@ export declare const deepCopy: (obj: Object) => any; | ||
}; | ||
export declare const randomInt: (min: number, max: number) => number; | ||
export declare const roundToFixed: (value: number, num?: number) => number; |
@@ -71,1 +71,7 @@ import logger from './logger'; | ||
}; | ||
export const randomInt = (min, max) => { | ||
return Math.floor(Math.random() * (max - min + 1) + min); | ||
}; | ||
export const roundToFixed = (value, num = 2) => { | ||
return Number(value.toFixed(num)); | ||
}; |
@@ -1,12 +0,9 @@ | ||
import BaseCall from './BaseCall'; | ||
import WebRTCCall from './WebRTCCall'; | ||
import { CallOptions } from './interfaces'; | ||
export default class Call extends BaseCall { | ||
screenShare: Call; | ||
export default class Call extends WebRTCCall { | ||
private _statsInterval; | ||
hangup(params?: any, execute?: boolean): void; | ||
startScreenShare(opts?: CallOptions): Promise<Call>; | ||
startScreenShare(opts?: CallOptions): Promise<WebRTCCall>; | ||
stopScreenShare(): void; | ||
setAudioOutDevice(deviceId: string): Promise<boolean>; | ||
protected _finalize(): void; | ||
private _stats; | ||
} |
@@ -11,5 +11,5 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
import logger from '../util/logger'; | ||
import BaseCall from './BaseCall'; | ||
import { getDisplayMedia, setMediaElementSinkId } from '../util/webrtc'; | ||
export default class Call extends BaseCall { | ||
import WebRTCCall from './WebRTCCall'; | ||
import { getDisplayMedia } from '../util/webrtc'; | ||
export default class Call extends WebRTCCall { | ||
constructor() { | ||
@@ -19,8 +19,2 @@ super(...arguments); | ||
} | ||
hangup(params = {}, execute = true) { | ||
if (this.screenShare instanceof Call) { | ||
this.screenShare.hangup(params, execute); | ||
} | ||
super.hangup(params, execute); | ||
} | ||
startScreenShare(opts) { | ||
@@ -48,12 +42,2 @@ return __awaiter(this, void 0, void 0, function* () { | ||
} | ||
setAudioOutDevice(deviceId) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this.options.speakerId = deviceId; | ||
const { remoteElement, speakerId } = this.options; | ||
if (remoteElement && speakerId) { | ||
return setMediaElementSinkId(remoteElement, speakerId); | ||
} | ||
return false; | ||
}); | ||
} | ||
_finalize() { | ||
@@ -60,0 +44,0 @@ this._stats(false); |
@@ -26,12 +26,11 @@ import { CallOptions } from './interfaces'; | ||
} | ||
export declare const NOTIFICATION_TYPE: { | ||
generic: string; | ||
[VertoMethod.Display]: string; | ||
[VertoMethod.Attach]: string; | ||
conferenceUpdate: string; | ||
callUpdate: string; | ||
vertoClientReady: string; | ||
userMediaError: string; | ||
refreshToken: string; | ||
}; | ||
export declare enum Notification { | ||
Generic = "event", | ||
ParticipantData = "participantData", | ||
ConferenceUpdate = "conferenceUpdate", | ||
CallUpdate = "callUpdate", | ||
VertoClientReady = "vertoClientReady", | ||
UserMediaError = "userMediaError", | ||
RefreshToken = "refreshToken" | ||
} | ||
export declare const DEFAULT_CALL_OPTIONS: CallOptions; | ||
@@ -38,0 +37,0 @@ export declare enum State { |
@@ -28,12 +28,12 @@ export var PeerType; | ||
})(VertoMethod || (VertoMethod = {})); | ||
export const NOTIFICATION_TYPE = { | ||
generic: 'event', | ||
[VertoMethod.Display]: 'participantData', | ||
[VertoMethod.Attach]: 'participantData', | ||
conferenceUpdate: 'conferenceUpdate', | ||
callUpdate: 'callUpdate', | ||
vertoClientReady: 'vertoClientReady', | ||
userMediaError: 'userMediaError', | ||
refreshToken: 'refreshToken', | ||
}; | ||
export var Notification; | ||
(function (Notification) { | ||
Notification["Generic"] = "event"; | ||
Notification["ParticipantData"] = "participantData"; | ||
Notification["ConferenceUpdate"] = "conferenceUpdate"; | ||
Notification["CallUpdate"] = "callUpdate"; | ||
Notification["VertoClientReady"] = "vertoClientReady"; | ||
Notification["UserMediaError"] = "userMediaError"; | ||
Notification["RefreshToken"] = "refreshToken"; | ||
})(Notification || (Notification = {})); | ||
export const DEFAULT_CALL_OPTIONS = { | ||
@@ -51,5 +51,2 @@ destinationNumber: '', | ||
userVariables: {}, | ||
googleMaxBitrate: 2048, | ||
googleMinBitrate: 0, | ||
googleStartBitrate: 1024, | ||
}; | ||
@@ -56,0 +53,0 @@ export var State; |
@@ -1,2 +0,2 @@ | ||
import { CallOptions } from './interfaces'; | ||
import { CallOptions, IVertoCanvasInfo, ICanvasInfo } from './interfaces'; | ||
declare const getUserMedia: (constraints: MediaStreamConstraints) => Promise<MediaStream>; | ||
@@ -27,2 +27,3 @@ declare const getDevices: (kind?: string, fullList?: boolean) => Promise<MediaDeviceInfo[]>; | ||
declare const sdpBitrateHack: (sdp: string, max: number, min: number, start: number) => string; | ||
export { getUserMedia, getDevices, scanResolutions, getMediaConstraints, assureDeviceId, removeUnsupportedConstraints, checkDeviceIdConstraints, sdpStereoHack, sdpMediaOrderHack, sdpBitrateHack, checkSubscribeResponse, destructSubscribeResponse, enableAudioTracks, disableAudioTracks, toggleAudioTracks, enableVideoTracks, disableVideoTracks, toggleVideoTracks, }; | ||
declare const mutateCanvasInfoData: (canvasInfo: IVertoCanvasInfo) => ICanvasInfo; | ||
export { getUserMedia, getDevices, scanResolutions, getMediaConstraints, assureDeviceId, removeUnsupportedConstraints, checkDeviceIdConstraints, sdpStereoHack, sdpMediaOrderHack, sdpBitrateHack, checkSubscribeResponse, destructSubscribeResponse, enableAudioTracks, disableAudioTracks, toggleAudioTracks, enableVideoTracks, disableVideoTracks, toggleVideoTracks, mutateCanvasInfoData, }; |
@@ -10,5 +10,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
}; | ||
import logger from '../util/logger'; | ||
import * as WebRTC from '../util/webrtc'; | ||
import { isDefined } from '../util/helpers'; | ||
import { isDefined, roundToFixed } from '../util/helpers'; | ||
import { DeviceType } from './constants'; | ||
@@ -257,2 +268,14 @@ const getUserMedia = (constraints) => __awaiter(void 0, void 0, void 0, function* () { | ||
}; | ||
export { getUserMedia, getDevices, scanResolutions, getMediaConstraints, assureDeviceId, removeUnsupportedConstraints, checkDeviceIdConstraints, sdpStereoHack, sdpMediaOrderHack, sdpBitrateHack, checkSubscribeResponse, destructSubscribeResponse, enableAudioTracks, disableAudioTracks, toggleAudioTracks, enableVideoTracks, disableVideoTracks, toggleVideoTracks, }; | ||
const mutateCanvasInfoData = (canvasInfo) => { | ||
const { canvasID, layoutFloorID, scale, canvasLayouts } = canvasInfo, rest = __rest(canvasInfo, ["canvasID", "layoutFloorID", "scale", "canvasLayouts"]); | ||
const layouts = []; | ||
let layoutOverlap = false; | ||
for (let i = 0; i < canvasLayouts.length; i++) { | ||
const layout = canvasLayouts[i]; | ||
const { memberID, audioPOS, xPOS, yPOS } = layout, rest = __rest(layout, ["memberID", "audioPOS", "xPOS", "yPOS"]); | ||
layoutOverlap = layoutOverlap || layout.overlap === 1; | ||
layouts.push(Object.assign({ startX: `${roundToFixed((layout.x / scale) * 100)}%`, startY: `${roundToFixed((layout.y / scale) * 100)}%`, percentageWidth: `${roundToFixed((layout.scale / scale) * 100)}%`, percentageHeight: `${roundToFixed((layout.hscale / scale) * 100)}%`, participantId: String(memberID), audioPos: audioPOS, xPos: xPOS, yPos: yPOS }, rest)); | ||
} | ||
return Object.assign(Object.assign({}, rest), { canvasId: canvasID, layoutFloorId: layoutFloorID, scale, canvasLayouts: layouts, layoutOverlap }); | ||
}; | ||
export { getUserMedia, getDevices, scanResolutions, getMediaConstraints, assureDeviceId, removeUnsupportedConstraints, checkDeviceIdConstraints, sdpStereoHack, sdpMediaOrderHack, sdpBitrateHack, checkSubscribeResponse, destructSubscribeResponse, enableAudioTracks, disableAudioTracks, toggleAudioTracks, enableVideoTracks, disableVideoTracks, toggleVideoTracks, mutateCanvasInfoData, }; |
@@ -30,46 +30,2 @@ export interface CallOptions { | ||
} | ||
export interface IWebRTCCall { | ||
id: string; | ||
state: string; | ||
prevState: string; | ||
direction: string; | ||
options: CallOptions; | ||
cause: string; | ||
causeCode: number; | ||
channels: string[]; | ||
role: string; | ||
extension: string; | ||
localStream: MediaStream; | ||
remoteStream: MediaStream; | ||
invite: () => void; | ||
answer: () => void; | ||
hangup: (params: any, execute: boolean) => void; | ||
transfer: (destination: string) => void; | ||
replace: (replaceCallID: string) => void; | ||
hold: () => void; | ||
unhold: () => void; | ||
toggleHold: () => void; | ||
dtmf: (dtmf: string) => void; | ||
message: (to: string, body: string) => void; | ||
muteAudio: () => void; | ||
unmuteAudio: () => void; | ||
toggleAudioMute: () => void; | ||
setAudioInDevice: (deviceId: string) => Promise<void>; | ||
muteVideo: () => void; | ||
unmuteVideo: () => void; | ||
toggleVideoMute: () => void; | ||
setVideoDevice: (deviceId: string) => Promise<void>; | ||
deaf: () => void; | ||
undeaf: () => void; | ||
toggleDeaf: () => void; | ||
setState: (state: any) => void; | ||
handleMessage: (msg: any) => void; | ||
_addChannel: (laChannel: any) => void; | ||
handleConferenceUpdate: (packet: any, pvtData: any) => Promise<string>; | ||
startScreenShare?: (opts?: object) => Promise<IWebRTCCall>; | ||
stopScreenShare?: () => void; | ||
setAudioOutDevice?: (deviceId: string) => Promise<boolean>; | ||
switchCamera?: () => void; | ||
setSpeakerPhone?: (flag: boolean) => void; | ||
} | ||
export interface ICantinaAuthParams { | ||
@@ -89,1 +45,70 @@ hostname?: string; | ||
} | ||
export interface VertoPvtData { | ||
callID: string; | ||
nodeId?: string; | ||
action: string; | ||
laChannel: string; | ||
laName: string; | ||
role: string; | ||
chatID: string; | ||
conferenceMemberID: number; | ||
canvasCount: string; | ||
modChannel: string; | ||
chatChannel: string; | ||
infoChannel: string; | ||
} | ||
export interface IVertoCanvasInfo { | ||
canvasID: number; | ||
totalLayers: number; | ||
layersUsed: number; | ||
layoutFloorID: number; | ||
layoutName: string; | ||
canvasLayouts: IVertoCanvasLayout[]; | ||
scale: number; | ||
} | ||
export interface IVertoCanvasLayout { | ||
x: number; | ||
y: number; | ||
scale: number; | ||
hscale: number; | ||
zoom: number; | ||
border: number; | ||
floor: number; | ||
overlap: number; | ||
screenWidth: number; | ||
screenHeight: number; | ||
xPOS: number; | ||
yPOS: number; | ||
audioPOS: string; | ||
memberID: number; | ||
} | ||
export interface ICanvasInfo { | ||
canvasId: number; | ||
totalLayers: number; | ||
layersUsed: number; | ||
layoutFloorId: number; | ||
layoutName: string; | ||
canvasLayouts: ICanvasLayout[]; | ||
scale: number; | ||
layoutOverlap: boolean; | ||
} | ||
export interface ICanvasLayout { | ||
x: number; | ||
y: number; | ||
startX: string; | ||
startY: string; | ||
percentageWidth: string; | ||
percentageHeight: string; | ||
scale: number; | ||
hscale: number; | ||
zoom: number; | ||
border: number; | ||
floor: number; | ||
overlap: number; | ||
screenWidth: number; | ||
screenHeight: number; | ||
xPos: number; | ||
yPos: number; | ||
audioPos: string; | ||
participantId: string; | ||
} |
import BrowserSession from '../BrowserSession'; | ||
declare class VertoHandler { | ||
session: BrowserSession; | ||
nodeId: string; | ||
constructor(session: BrowserSession); | ||
private _ack; | ||
handleMessage(msg: any): Promise<void>; | ||
private _retrieveCallId; | ||
private _handlePvtEvent; | ||
private _handleSessionEvent; | ||
} | ||
export default VertoHandler; | ||
declare const _default: (session: BrowserSession, msg: any) => any; | ||
export default _default; |
@@ -11,203 +11,110 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
import logger from '../util/logger'; | ||
import Conference from './Conference'; | ||
import Call from './Call'; | ||
import { checkSubscribeResponse } from './helpers'; | ||
import { Result } from '../messages/Verto'; | ||
import { SwEvent } from '../util/constants'; | ||
import { VertoMethod, NOTIFICATION_TYPE } from './constants'; | ||
import { trigger, deRegister } from '../services/Handler'; | ||
import { State, ConferenceAction } from './constants'; | ||
import { MCULayoutEventHandler } from './LayoutHandler'; | ||
class VertoHandler { | ||
constructor(session) { | ||
this.session = session; | ||
import { VertoMethod, Notification } from './constants'; | ||
import { trigger, registerOnce } from '../services/Handler'; | ||
import { State } from './constants'; | ||
const CONF_READY = 'CONF_READY'; | ||
const _handlePvtEvent = (session, pvtData) => __awaiter(void 0, void 0, void 0, function* () { | ||
const { action, callID } = pvtData; | ||
if (!callID || !session.calls[callID]) { | ||
return logger.warn('Verto pvtData with invalid or unknown callID.'); | ||
} | ||
_ack(id, method) { | ||
const msg = new Result(id, method); | ||
if (this.nodeId) { | ||
msg.targetNodeId = this.nodeId; | ||
} | ||
this.session.execute(msg); | ||
} | ||
handleMessage(msg) { | ||
const { session } = this; | ||
const { id, method, params } = msg; | ||
const { callID, eventChannel, eventType } = params; | ||
const attach = method === VertoMethod.Attach; | ||
if (eventType === 'channelPvtData') { | ||
return this._handlePvtEvent(params.pvtData); | ||
} | ||
if (callID && session.calls.hasOwnProperty(callID)) { | ||
if (attach) { | ||
session.calls[callID].hangup({}, false); | ||
switch (action) { | ||
case 'conference-liveArray-join': | ||
if (!session.calls[callID].conference) { | ||
session.calls[callID].conference = new Conference(session); | ||
} | ||
else { | ||
session.calls[callID].handleMessage(msg); | ||
this._ack(id, method); | ||
return; | ||
session.calls[callID].conference.join(pvtData); | ||
trigger(callID, null, CONF_READY); | ||
break; | ||
case 'conference-liveArray-part': | ||
if (session.calls[callID].conference) { | ||
session.calls[callID].conference.part(pvtData); | ||
} | ||
} | ||
const _buildCall = () => { | ||
const call = new Call(session, { | ||
id: callID, | ||
remoteSdp: params.sdp, | ||
destinationNumber: params.callee_id_number, | ||
remoteCallerName: params.caller_id_name, | ||
remoteCallerNumber: params.caller_id_number, | ||
callerName: params.callee_id_name, | ||
callerNumber: params.callee_id_number, | ||
attach | ||
}); | ||
call.nodeId = this.nodeId; | ||
return call; | ||
}; | ||
switch (method) { | ||
case VertoMethod.Punt: | ||
session.disconnect(); | ||
break; | ||
case VertoMethod.Invite: { | ||
const call = _buildCall(); | ||
call.setState(State.Ringing); | ||
this._ack(id, method); | ||
break; | ||
} | ||
case VertoMethod.Attach: { | ||
const call = _buildCall(); | ||
if (this.session.autoRecoverCalls) { | ||
call.answer(); | ||
} | ||
else { | ||
call.setState(State.Recovering); | ||
} | ||
call.handleMessage(msg); | ||
break; | ||
} | ||
case VertoMethod.Event: | ||
case 'webrtc.event': | ||
if (!eventChannel) { | ||
logger.error('Verto received an unknown event:', params); | ||
return; | ||
} | ||
const protocol = session.relayProtocol; | ||
const firstValue = eventChannel.split('.')[0]; | ||
if (session._existsSubscription(protocol, eventChannel)) { | ||
trigger(protocol, params, eventChannel); | ||
} | ||
else if (eventChannel === session.sessionid) { | ||
this._handleSessionEvent(params.eventData); | ||
} | ||
else if (session._existsSubscription(protocol, firstValue)) { | ||
trigger(protocol, params, firstValue); | ||
} | ||
else if (session.calls.hasOwnProperty(eventChannel)) { | ||
session.calls[eventChannel].handleMessage(msg); | ||
} | ||
else { | ||
trigger(SwEvent.Notification, params, session.uuid); | ||
} | ||
break; | ||
case VertoMethod.Info: | ||
params.type = NOTIFICATION_TYPE.generic; | ||
trigger(SwEvent.Notification, params, session.uuid); | ||
break; | ||
case VertoMethod.ClientReady: | ||
params.type = NOTIFICATION_TYPE.vertoClientReady; | ||
trigger(SwEvent.Notification, params, session.uuid); | ||
break; | ||
default: | ||
logger.warn('Verto message unknown method:', msg); | ||
} | ||
break; | ||
} | ||
_retrieveCallId(packet, laChannel) { | ||
const callIds = Object.keys(this.session.calls); | ||
if (packet.action === 'bootObj') { | ||
const me = packet.data.find((pr) => callIds.includes(pr[0])); | ||
if (me instanceof Array) { | ||
return me[0]; | ||
} | ||
}); | ||
const _handleSessionEvent = (session, eventData) => { | ||
const { contentType, callID } = eventData; | ||
if (!callID || !session.calls.hasOwnProperty(callID)) { | ||
return logger.warn('Unhandled session event:', eventData); | ||
} | ||
const call = session.calls[callID]; | ||
if (!call.conference) { | ||
return registerOnce(callID, _handleSessionEvent.bind(this, session, eventData), CONF_READY); | ||
} | ||
switch (contentType) { | ||
case 'layout-info': | ||
case 'layer-info': | ||
call.conference.updateLayouts(eventData); | ||
break; | ||
case 'logo-info': | ||
call.conference.updateLogo(eventData); | ||
break; | ||
} | ||
}; | ||
const _buildCall = (session, params, attach, nodeId) => { | ||
const call = new Call(session, { | ||
id: params.callID, | ||
remoteSdp: params.sdp, | ||
destinationNumber: params.callee_id_number, | ||
remoteCallerName: params.caller_id_name, | ||
remoteCallerNumber: params.caller_id_number, | ||
callerName: params.callee_id_name, | ||
callerNumber: params.callee_id_number, | ||
attach | ||
}); | ||
call.nodeId = nodeId; | ||
return call; | ||
}; | ||
export default (session, msg) => { | ||
const { id, method, nodeId, params } = msg; | ||
const { callID, eventChannel, eventType } = params; | ||
if (eventType === 'channelPvtData') { | ||
params.pvtData.nodeId = nodeId; | ||
return _handlePvtEvent(session, params.pvtData); | ||
} | ||
if (eventChannel === session.sessionid) { | ||
return _handleSessionEvent(session, params.eventData); | ||
} | ||
if (callID && session.calls.hasOwnProperty(callID)) { | ||
trigger(callID, params, method); | ||
const msg = new Result(id, method); | ||
msg.targetNodeId = nodeId; | ||
return session.execute(msg); | ||
} | ||
const attach = method === VertoMethod.Attach; | ||
switch (method) { | ||
case VertoMethod.Punt: | ||
return session.disconnect(); | ||
case VertoMethod.Invite: { | ||
const call = _buildCall(session, params, attach, nodeId); | ||
call.setState(State.Ringing); | ||
const msg = new Result(id, method); | ||
msg.targetNodeId = nodeId; | ||
return session.execute(msg); | ||
} | ||
else { | ||
return callIds.find((id) => this.session.calls[id].channels.includes(laChannel)); | ||
case VertoMethod.Attach: { | ||
const call = _buildCall(session, params, attach, nodeId); | ||
return trigger(call.id, params, method); | ||
} | ||
} | ||
_handlePvtEvent(pvtData) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { session } = this; | ||
const protocol = session.relayProtocol; | ||
const { action, laChannel, laName, chatChannel, infoChannel, modChannel, conferenceMemberID, role, callID } = pvtData; | ||
switch (action) { | ||
case 'conference-liveArray-join': { | ||
const _liveArrayBootstrap = () => { | ||
session.vertoBroadcast({ nodeId: this.nodeId, channel: laChannel, data: { liveArray: { command: 'bootstrap', context: laChannel, name: laName } } }); | ||
}; | ||
const tmp = { | ||
nodeId: this.nodeId, | ||
channels: [laChannel], | ||
handler: ({ data: packet }) => { | ||
const id = callID || this._retrieveCallId(packet, laChannel); | ||
if (id && session.calls.hasOwnProperty(id)) { | ||
const call = session.calls[id]; | ||
call._addChannel(laChannel); | ||
call.extension = laName; | ||
call.handleConferenceUpdate(packet, pvtData) | ||
.then(error => { | ||
if (error === 'INVALID_PACKET') { | ||
_liveArrayBootstrap(); | ||
} | ||
}); | ||
} | ||
} | ||
}; | ||
const result = yield session.vertoSubscribe(tmp) | ||
.catch(error => { | ||
logger.error('liveArray subscription error:', error); | ||
}); | ||
if (checkSubscribeResponse(result, laChannel)) { | ||
_liveArrayBootstrap(); | ||
} | ||
break; | ||
} | ||
case 'conference-liveArray-part': { | ||
let call = null; | ||
if (laChannel && session._existsSubscription(protocol, laChannel)) { | ||
const { callId = null } = session.subscriptions[protocol][laChannel]; | ||
call = session.calls[callId] || null; | ||
if (callId !== null) { | ||
const notification = { type: NOTIFICATION_TYPE.conferenceUpdate, action: ConferenceAction.Leave, conferenceName: laName, participantId: Number(conferenceMemberID), role }; | ||
if (!trigger(SwEvent.Notification, notification, callId, false)) { | ||
trigger(SwEvent.Notification, notification, session.uuid); | ||
} | ||
if (call === null) { | ||
deRegister(SwEvent.Notification, null, callId); | ||
} | ||
} | ||
} | ||
const channels = [laChannel, chatChannel, infoChannel, modChannel]; | ||
session.vertoUnsubscribe({ nodeId: this.nodeId, channels }) | ||
.then(({ unsubscribedChannels = [] }) => { | ||
if (call) { | ||
call.channels = call.channels.filter(c => !unsubscribedChannels.includes(c)); | ||
} | ||
}) | ||
.catch(error => { | ||
logger.error('liveArray unsubscribe error:', error); | ||
}); | ||
break; | ||
} | ||
case VertoMethod.Event: | ||
case 'webrtc.event': | ||
if (eventChannel && trigger(eventChannel, params)) { | ||
return; | ||
} | ||
}); | ||
logger.warn('Unhandled verto event:', msg); | ||
break; | ||
case VertoMethod.Info: | ||
params.type = Notification.Generic; | ||
return trigger(SwEvent.Notification, params, session.uuid); | ||
case VertoMethod.ClientReady: | ||
params.type = Notification.VertoClientReady; | ||
return trigger(SwEvent.Notification, params, session.uuid); | ||
default: | ||
logger.warn('Unknown Verto method:', msg); | ||
} | ||
_handleSessionEvent(eventData) { | ||
switch (eventData.contentType) { | ||
case 'layout-info': | ||
case 'layer-info': | ||
MCULayoutEventHandler(this.session, eventData); | ||
break; | ||
case 'logo-info': { | ||
const notification = { type: NOTIFICATION_TYPE.conferenceUpdate, action: ConferenceAction.LogoInfo, logo: eventData.logoURL }; | ||
trigger(SwEvent.Notification, notification, this.session.uuid); | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
export default VertoHandler; | ||
}; |
import Relay from './src/SignalWire'; | ||
import Verto from './src/Verto'; | ||
import CantinaAuth from '../common/src/webrtc/CantinaAuth'; | ||
export declare const VERSION = "1.3.0-alpha.1"; | ||
export declare const VERSION = "1.3.0-alpha.2"; | ||
export { Relay, Verto, CantinaAuth }; | ||
export * from '../common/src/util/interfaces'; |
@@ -5,4 +5,4 @@ import Relay from './src/SignalWire'; | ||
import CantinaAuth from '../common/src/webrtc/CantinaAuth'; | ||
export const VERSION = '1.3.0-alpha.1'; | ||
export const VERSION = '1.3.0-alpha.2'; | ||
setAgentName(`JavaScript SDK/${VERSION}`); | ||
export { Relay, Verto, CantinaAuth }; |
import BrowserSession from '../../common/src/BrowserSession'; | ||
import BaseMessage from '../../common/src/messages/BaseMessage'; | ||
import { CallOptions } from '../../common/src/webrtc/interfaces'; | ||
import Call from '../../common/src/webrtc/Call'; | ||
export default class SignalWire extends BrowserSession { | ||
execute(message: BaseMessage): any; | ||
newCall(options: CallOptions): Promise<Call>; | ||
} |
@@ -11,17 +11,4 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
import BrowserSession from '../../common/src/BrowserSession'; | ||
import { Execute } from '../../common/src/messages/Blade'; | ||
import BaseRequest from '../../common/src/messages/verto/BaseRequest'; | ||
import Call from '../../common/src/webrtc/Call'; | ||
export default class SignalWire extends BrowserSession { | ||
execute(message) { | ||
let msg = message; | ||
if (message instanceof BaseRequest) { | ||
const params = { message: message.request }; | ||
if (message.targetNodeId) { | ||
params.node_id = message.targetNodeId; | ||
} | ||
msg = new Execute({ protocol: this.relayProtocol, method: 'message', params }); | ||
} | ||
return super.execute(msg); | ||
} | ||
newCall(options) { | ||
@@ -28,0 +15,0 @@ return __awaiter(this, void 0, void 0, function* () { |
@@ -5,12 +5,15 @@ import BrowserSession from '../../common/src/BrowserSession'; | ||
import Call from '../../common/src/webrtc/Call'; | ||
import BaseMessage from '../../common/src/messages/BaseMessage'; | ||
export declare const VERTO_PROTOCOL = "verto-protocol"; | ||
export default class Verto extends BrowserSession { | ||
relayProtocol: string; | ||
timeoutErrorCode: number; | ||
validateOptions(): boolean; | ||
newCall(options: CallOptions): Call; | ||
broadcast(params: BroadcastParams): void; | ||
broadcast(params: BroadcastParams): any; | ||
subscribe(params: SubscribeParams): Promise<any>; | ||
unsubscribe(params: SubscribeParams): Promise<any>; | ||
unsubscribe(params: SubscribeParams): any; | ||
_wrapInExecute(message: BaseMessage): BaseMessage; | ||
protected _onSocketOpen(): Promise<void>; | ||
protected _onSocketMessage(msg: any): void; | ||
} |
@@ -22,2 +22,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
this.relayProtocol = VERTO_PROTOCOL; | ||
this.timeoutErrorCode = -329990; | ||
} | ||
@@ -46,2 +47,5 @@ validateOptions() { | ||
} | ||
_wrapInExecute(message) { | ||
return message; | ||
} | ||
_onSocketOpen() { | ||
@@ -60,3 +64,5 @@ return __awaiter(this, void 0, void 0, function* () { | ||
this.sessionid = response.sessid; | ||
localStorage.setItem(SESSION_ID, this.sessionid); | ||
if (!this.incognito) { | ||
localStorage.setItem(SESSION_ID, this.sessionid); | ||
} | ||
trigger(SwEvent.Ready, this, this.uuid); | ||
@@ -67,5 +73,4 @@ } | ||
_onSocketMessage(msg) { | ||
const handler = new VertoHandler(this); | ||
handler.handleMessage(msg); | ||
VertoHandler(this, msg); | ||
} | ||
} |
{ | ||
"name": "@signalwire/js", | ||
"version": "1.3.0-alpha.1", | ||
"version": "1.3.0-alpha.2", | ||
"description": "Relay SDK for JavaScript to connect to SignalWire.", | ||
@@ -43,8 +43,8 @@ "author": "SignalWire Team <open.source@signalwire.com>", | ||
"dependencies": { | ||
"loglevel": "^1.6.4", | ||
"uuid": "^3.3.3" | ||
"loglevel": "^1.6.7", | ||
"uuid": "^7.0.2" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^24.0.21", | ||
"@types/uuid": "^3.4.6", | ||
"@types/jest": "^25.1.4", | ||
"@types/uuid": "^7.0.0", | ||
"babel-core": "^6.26.3", | ||
@@ -54,7 +54,7 @@ "babel-loader": "^7.1.5", | ||
"babel-preset-env": "^1.7.0", | ||
"jest": "^24.9.0", | ||
"ts-jest": "^24.1.0", | ||
"ts-loader": "^5.4.5", | ||
"tslint": "^5.20.0", | ||
"typescript": "^3.6.4", | ||
"jest": "^25.1.0", | ||
"ts-jest": "^25.2.1", | ||
"ts-loader": "^6.2.1", | ||
"tslint": "^6.1.0", | ||
"typescript": "^3.8.3", | ||
"webpack": "^4.41.2", | ||
@@ -61,0 +61,0 @@ "webpack-cli": "^3.3.10", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
77
298470
3994
+ Addeduuid@7.0.3(transitive)
- Removeduuid@3.4.0(transitive)
Updatedloglevel@^1.6.7
Updateduuid@^7.0.2