Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function() {
- var n = this,
- i = function() {};
- if (function(t, n) {
- var i = "VI_WEBRTC_STATE_IDLE",
- o = "VI_WEBRTC_STATE_WS_CONNECTING",
- s = "VI_WEBRTC_STATE_WS_CONNECTED",
- a = "VI_WEBRTC_STATE_WS_CONNECTED",
- r = t.VI_CALL_STATE_ALERTING = "ALERTING",
- c = t.VI_CALL_STATE_PROGRESSING = "PROGRESSING",
- l = t.VI_CALL_STATE_CONNECTED = "CONNECTED",
- d = t.VI_CALL_STATE_ENDED = "ENDED",
- h = 6e3,
- u = 1e4;
- t.ZingayaAPI = function(t, n) {
- function f(e) {
- return J && (e.sdp = e.sdp.replace(/(a=mid:video.*\r\n)/g, "$1b=AS:" + J + "\r\n")), e
- }
- function p() {
- B && (clearTimeout(B), B = null, G = setTimeout(Te, w))
- }
- var C, m, g, v, y, S, R, T, I, E, w = 3e4,
- M = [],
- O = [],
- A = !1 !== n,
- P = function() {
- return M.length ? M.pop() : document.createElement("audio")
- },
- b = function(e) {
- m(e, null), M.push(e)
- },
- N = function() {
- return O.length ? O.pop() : document.createElement("video")
- },
- U = function(e) {
- m(e, null), O.push(e)
- },
- _ = function(e) {
- if (e) {
- if (e.audioTracks) return e.audioTracks;
- if (e.getAudioTracks) return e.getAudioTracks()
- }
- return null
- },
- L = function(e) {
- if (e) {
- if (e.videoTracks) return e.videoTracks;
- if (e.getVideoTracks) return e.getVideoTracks()
- }
- return null
- },
- F = function(e, t) {
- if (e)
- for (var n in e) e[n].enabled = t
- },
- D = t === !0 ? !0 : !1,
- V = "wss",
- x = null,
- z = i,
- k = [],
- H = !1,
- W = !1,
- X = !0,
- j = null,
- G = null,
- B = null,
- q = 1,
- J = null;
- this.setVideoBandwidth = function(e) {
- J = e
- };
- var K, $, Z = function() {
- y = "undefined" != typeof webkitRTCPeerConnection, S = "undefined" != typeof mozRTCPeerConnection, R = "undefined" != typeof MediaStreamTrack && "undefined" != typeof MediaStreamTrack.getSources || navigator.mediaDevices && navigator.mediaDevices.enumerateDevices, T = null, I = null, E = null, S && (v = mozRTCIceCandidate, g = mozRTCPeerConnection, C = navigator.mozGetUserMedia.bind(navigator), m = function(e, t) {
- t ? (e.mozSrcObject = t, e.load(), e.play()) : (e.mozSrcObject = null, e.load())
- }), y && (g = webkitRTCPeerConnection, v = RTCIceCandidate, C = navigator.webkitGetUserMedia.bind(navigator), m = function(e, t) {
- t ? (e.src = URL.createObjectURL(t), e.load(), e.play()) : e.pause()
- })
- },
- Y = null,
- Q = {},
- ee = {},
- te = 0,
- ne = function(e) {
- "function" == typeof this.writeLog && this.writeLog(e)
- }.bind(this),
- ie = function(e) {
- "function" == typeof this.writeTrace && this.writeTrace(e)
- }.bind(this),
- oe = function(e) {
- return z != a ? (ne(e + " called while in state " + z), !1) : !0
- },
- se = {
- year: "numeric",
- month: "numeric",
- day: "numeric"
- };
- this.writeLog = function(e) {
- BXIM.webrtc.phoneLog("VI WebRTC: " + (new Date).toLocaleTimeString("en-US", se) + " " + e)
- }, this.writeTrace = function(e) {
- BXIM.webrtc.phoneLog("VI WebRTC: " + (new Date).toLocaleTimeString("en-US", se) + " " + e)
- }, this.onConnectionEstablished = null, this.onConnectionFailed = null, this.onConnectionClosed = null, this.onLoginSuccessful = null, this.onLoginFailed = null, this.onIncomingCall = null, this.onCallRinging = null, this.onCallMediaStarted = null, this.onCallConnected = null, this.onCallEnded = null, this.onCallFailed = null, this.onSIPInfoReceived = null, this.onInstantMessageReceived = null, this.onTransferComplete = null, this.onTransferFailed = null, this.onNetStatsReceived = null, this.onRTCStatsCollected = null, this.onHandleRoster = null, this.onHandleRosterPresence = null, this.onHandleMessage = null, this.onHandleSelfPresence = null, this.onHandleChatState = null, this.onHandleMessageEvent = null, this.onHandleMessageRemoved = null, this.onHandleMessageModified = null, this.onHandleSubscription = null, this.onHandleRosterItem = null, this.onCallRemoteFunctionError = null, this.onIMError = null, this.onIMRosterError = null, this.onMUCError = null, this.onMUCRoomCreation = null, this.onMUCSubject = null, this.onMUCInfo = null, this.onMUCMessage = null, this.onMUCInvitation = null, this.onMUCInviteDecline = null, this.onMUCParticipantPresence = null, this.onMUCNewParticipant = null, this.onMUCParticipantExit = null, this.onMUCRooms = null, this.onMUCParticipants = null, this.onMUCBanList = null, this.onMUCHistory = null, this.onMUCMessageModified = null, this.onMUCMessageRemoved = null, this.onMUCChatState = null, this.onHistory = null, this.onUCConnected = null, this.onUCDisconnected = null, this.onVoicemail = null, this.onCheckComplete = null, this.onRemoteScreenCaptureStarted = null, this.onCallICETimeout = null;
- var ae = function(e, t) {
- "function" == typeof this.onRTCStatsCollected && this.onRTCStatsCollected(e, t)
- }.bind(this),
- re = function(e, t) {
- "function" == typeof this.onRemoteScreenCaptureStarted && this.onRemoteScreenCaptureStarted(e, t)
- }.bind(this),
- ce = function(e) {
- "function" == typeof this.onCallICETimeout && this.onCallICETimeout(e)
- }.bind(this),
- le = function(e) {
- var t = {};
- for (var n in e)("X-" == n.substring(0, 2) || "VI-CallData" == n) && (t[n] = e[n]);
- return t
- },
- de = function(e) {
- for (var t in e)
- if ("X-DirectCall" == t) return "true" == e[t] ? !0 : !1;
- return !1
- },
- he = function() {
- te = 0;
- for (var e in Q) te++
- },
- ue = function(e) {
- Q[e.id()] = e, he()
- },
- fe = function(e) {
- delete Q[e], he()
- }.bind(this);
- Z();
- var pe = function(e) {
- for (var t = "", n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", i = 0; e > i; i++) t += n.charAt(Math.floor(Math.random() * n.length));
- return t
- },
- Ce = function() {};
- this.muteMicrophone = function(e) {
- H = e, Y && F(_(Y), !e)
- }, this.sendVideo = function(e) {
- X = e, Y && F(L(Y), e)
- }, this.mutePlayback = function(e) {
- W = e;
- for (var t in ee) ee[t].updateSpeakerMuteState()
- }, this.setPlaybackVolume = function(e) {
- q = e;
- for (var t in ee) ee[t].setPlaybackVolume(e)
- }, this.getCalls = function() {
- var e = [];
- for (var t in Q) e.push(t);
- return e
- }, this.setLocalVideoSink = function(e) {
- K = e, Y && m(e, Y)
- }, this.setRemoteSinksContainerId = function(e) {
- $ = e
- }, this.stopLocalStream = function() {
- Y && (Y.active && Y.getTracks().forEach(function(e) {
- e.stop()
- }), Y = null)
- }.bind(this), this.destroy = function() {
- this.disconnect(), this.stopLocalStream()
- }.bind(this), this.disconnect = function() {
- x && (Re(), x.onclose = null, x.close(), ve())
- }, this.useAudioSource = function(e, t, n) {
- R && (T = e, this.requestMedia(D, t, n, !0))
- }.bind(this), this.useVideoSource = function(e, t, n) {
- R && (I = e, this.requestMedia(!0, t, n, !0))
- }.bind(this), this.setConstraints = function(e, t, n, i) {
- E = e, i === !0 && this.requestMedia(D, t, n, D)
- }.bind(this), this.requestMedia = function(e, t, n, i) {
- var o, s = navigator.mediaDevices && navigator.mediaDevices.enumerateDevices && "undefined" == typeof MediaStreamTrack && "undefined" == typeof MediaStreamTrack.getSources ? "deviceId" : "sourceId";
- null === T && null === I ? o = {
- audio: !0,
- video: e === !0 ? !0 : !1
- } : null !== T && null !== I ? o = "sourceId" == s ? {
- audio: {
- mandatory: {
- sourceId: T
- }
- },
- video: {
- mandatory: {
- sourceId: I
- }
- }
- } : {
- audio: {
- deviceId: {
- exact: T
- }
- },
- video: {
- deviceId: {
- exact: I
- }
- }
- } : null !== T ? o = "sourceId" == s ? {
- audio: {
- mandatory: {
- sourceId: T
- }
- },
- video: e === !0 ? !0 : !1
- } : {
- audio: {
- deviceId: {
- exact: T
- }
- },
- video: e === !0 ? !0 : !1
- } : null !== I && (o = "sourceId" == s ? {
- audio: !0,
- video: {
- mandatory: {
- sourceId: I
- }
- }
- } : {
- audio: !0,
- video: {
- deviceId: {
- exact: I
- }
- }
- }), null !== E && (o.video = {}, "undefined" != typeof E.mandatory && (o.video.mandatory = E.mandatory), "undefined" != typeof E.optional ? (o.video.optional = E.optional, null !== I && ("sourceId" == s ? o.video.mandatory.sourceId = I : o.video.deviceId = {
- exact: I
- })) : null !== I && ("sourceId" == s ? o.video.mandatory.sourceId = I : o.video.deviceId = {
- exact: I
- })), Y && i && this.stopLocalStream(), "undefined" != typeof o.video.mandatory && "undefined" != typeof o.video.mandatory.chromeMediaSourceId && (o.audio = !1), C(o, function(e) {
- this.gUM_success(e, t)
- }.bind(this), function(e) {
- this.gUM_error(e, n)
- }.bind(this))
- }.bind(this), this.gUM_error = function(e, t) {
- ne("Media access rejected: " + e.name), "function" == typeof t && t(e.name)
- }.bind(this), this.gUM_success = function(e, t) {
- var n;
- if (Y) {
- Y.active && Y.getTracks().forEach(function(e) {
- e.stop()
- });
- for (n in ee) ee[n].setLocalStream(null)
- }
- ne("Media access granted"), Y = e, F(_(Y), !H), K && m(K, e);
- for (n in ee) ee[n].setLocalStream(Y);
- "function" == typeof t && t();
- for (n in Ie) Ee(n, Ie[n]);
- Ie = {}
- }.bind(this), this.shareScreen = function() {
- "undefined" != typeof getScreenId ? getScreenId(function(e, t, n) {
- C(n, function(e) {
- j = e;
- for (var t in ee) ee[t].isDirect() && ee[t].addScreenSharing(j)
- }, function(e) {
- ne(e)
- })
- }) : ne("No screensharing extension is available")
- }, this.getRemoteParty = function(e) {
- return Q[e] ? Q[e].getRemoteParty() : null
- }, this.getCallState = function(e) {
- return Q[e] ? Q[e].getState() : null
- }, this.setCallActive = function(e, t) {
- return Q[e] ? (t ? this.unholdCall(e) : this.holdCall(e), Q[e].setStreamsActive(t)) : void 0
- }, this.isCallActive = function(e) {
- return Q[e] ? Q[e].streamsAreActive() : !1
- }, this.connectTo = function(e, t, n, s) {
- if (z == i) try {
- x = new WebSocket(V + "://" + e + "/" + (s || "platform") + "?version=2&client=" + (S ? "firefox" : "chrome") + "&referrer=" + encodeURIComponent(t) + "&extra=" + encodeURIComponent(n) + "&video=" + (D === !0 ? "true" : "false") + "&q=" + pe(12)), z = o, x.onopen = Se, x.onclose = Re, x.onerror = ye, x.onmessage = Oe
- } catch (a) {
- ne("WebSocket Error: " + a)
- } else ne("Error: called connectTo while in state " + z)
- }.bind(this), this.startPreFlightCheck = function(e, t) {
- oe("__startPreFlightCheck") && Ne("__startPreFlightCheck", [!!e, !!t])
- }, this.login = function(e, t, n) {
- oe("login") && Ne("login", [e, t, n ? n : null])
- }, this.loginStage2 = function(e, t, n) {
- oe("loginStage2") && Ne("loginStage2", [e, t, n ? n : null])
- }, this.loginGenerateOneTimeKey = function(e) {
- oe("loginGenerateOneTimeKey") && Ne("loginGenerateOneTimeKey", [e])
- }, this.loginUsingOneTimeKey = function(e, t, n) {
- oe("loginUsingOneTimeKey") && Ne("loginUsingOneTimeKey", [e, t, n ? n : null])
- }, this.setOperatorACDStatus = function(e) {
- oe("setOperatorACDStatus") && Ne("setOperatorACDStatus", [e])
- }, this.callTo = function(e, t, n, i) {
- var o = pe(36);
- n = le("undefined" == typeof n ? {} : n);
- var s = new Pe(o, c, e, "");
- if (s.setHeaders(n), ue(s), de(n)) {
- var a = we(o, !0);
- a.outgoingCall()
- } else Ne("createCall", [-1, e, t, o, null, null, n, i]);
- return o
- }, this.transferCall = function(e, t) {
- for (var n = [e, t], i = 0; i < n.length; i++) {
- var o = Q[n[i]];
- if (!o) return void ne("ERROR: trying to transfer unknown call " + o.id());
- if (o.getState() != l) return void ne("ERROR: trying to transfer call " + o.id() + " in state " + o.getState())
- }
- Ne("transferCall", [e, t])
- }, this.hangupCall = function(e, t) {
- var n = Q[e];
- n ? n.getState() == r ? Ne("rejectCall", [e, !0, le(t)]) : Ne("disconnectCall", [e, le(t)]) : ne("ERROR: trying to hangup unknown call " + e)
- }, this.rejectCall = function(e, t, n) {
- var i = Q[e];
- i ? i.getState() == r ? Ne("rejectCall", [e, !0, le(n)]) : ne("ERROR: trying to reject call " + e + " in state " + i.getState()) : ne("ERROR: trying to reject unknown call " + e)
- }, this.answerCall = function(e, t) {
- var n = Q[e];
- if (n)
- if (n.getState() == r)
- if (de(n.getHeaders())) {
- var i = n.getPeerConnection();
- i.createAnswer()
- } else Ne("acceptCall", [e, le(t)]);
- else ne("ERROR: trying to answer call " + e + " in state " + n.getState());
- else ne("ERROR: trying to answer unknown call " + e)
- }, this.sendDigit = function(e, t) {
- var n = Q[e];
- n ? n.getState() == l ? Ne("sendDTMF", [e, t]) : ne("ERROR: trying to send digit to call " + e + " in state " + n.getState()) : ne("ERROR: trying to send digit to unknown call " + e)
- }, this.holdCall = function(e) {
- var t = Q[e];
- t ? t.getState() == l ? Ne("hold", [e]) : ne("ERROR: trying to hold call " + e + " in state " + t.getState()) : ne("ERROR: trying to hold unknown call " + e)
- }, this.unholdCall = function(e) {
- var t = Q[e];
- t ? t.getState() == l ? Ne("unhold", [e]) : ne("ERROR: trying to unhold call " + e + " in state " + t.getState()) : ne("ERROR: trying to unhold unknown call " + e)
- }, this.voicemailPromptFinished = function(e) {
- var t = Q[e];
- t ? Ne("promptFinished", [e]) : ne("ERROR: trying to record voicemail for unknown call " + e)
- }, this.sendSIPInfo = function(e, t, n, i, o) {
- var s = Q[e];
- s ? s.getState() == l || s.getState() == r || s.getState() == c ? Ne("sendSIPInfo", [e, t, n, i, le(o)]) : ne("ERROR: trying to send SIP Info to call " + e + " in state " + s.getState()) : ne("ERROR: trying to send SIP Info to unknown call " + e)
- };
- var me = this.sendSIPInfo.bind(this);
- this.setDesiredVideoBandwidth = function(e) {
- oe("setDesiredVideoBandwidth") && Ne("setDesiredVideoBandwidth", [e])
- }, this.sendInstantMessage = function(e, t) {
- this.sendSIPInfo(e, "application", "zingaya-im", t, {})
- }, this.sendTextMessage = function(e, t, n) {
- oe("sendMessage") && Ne("sendMessage", [e, t, n])
- }, this.editTextMessage = function(e, t, n) {
- oe("editMessage") && Ne("editMessage", [e, t, n])
- }, this.removeTextMessage = function(e, t) {
- oe("removeMessage") && Ne("removeMessage", [e, t])
- }, this.sendStatus = function(e, t) {
- oe("sendStatus") && Ne("sendStatus", [e, t])
- }, this.sendChatState = function(e, t) {
- oe("sendChatState") && Ne("sendChatState", [e, t])
- }, this.raiseMessageEvent = function(e, t, n) {
- oe("raiseMessageEvent") && Ne("raiseMessageEvent", [e, t, n])
- }, this.addRoster = function(e, t, n) {
- oe("addRoster") && Ne("addRoster", [e, t, n])
- }, this.addRosterItemGroup = function(e, t) {
- oe("addRosterItemGroup") && Ne("addRosterItemGroup", [e, t])
- }, this.delRosterItemGroup = function(e, t) {
- oe("delRosterItemGroup") && Ne("delRosterItemGroup", [e, t])
- }, this.moveRosterItemGroup = function(e, t, n) {
- oe("moveRosterItemGroup") && Ne("moveRosterItemGroup", [e, t, n])
- }, this.renameRosterItem = function(e, t) {
- oe("renameRosterItem") && Ne("renameRosterItem", [e, t])
- }, this.removeRoster = function(e) {
- oe("removeRoster") && Ne("removeRoster", [e])
- }, this.joinMUC = function(e, t, n) {
- oe("joinMUC") && Ne("joinMUC", [e, t, n])
- }, this.leaveMUC = function(e, t) {
- oe("leaveMUC") && Ne("leaveMUC", [e, t])
- }, this.sendMUCMessage = function(e, t, n) {
- oe("sendMUCMessage") && Ne("sendMUCMessage", [e, t, n])
- }, this.editMUCMessage = function(e, t, n) {
- oe("editMUCMessage") && Ne("editMUCMessage", [e, t, n])
- }, this.removeMUCMessage = function(e, t) {
- oe("removeMUCMessage") && Ne("removeMUCMessage", [e, t])
- }, this.inviteMUC = function(e, t, n) {
- oe("inviteMUC") && Ne("inviteMUC", [e, t, n])
- }, this.declineMUCinvitation = function(e, t, n) {
- oe("declineMUCinvitation") && Ne("declineMUCinvitation", [e, t, n])
- }, this.ucReconnect = function() {
- oe("ucReconnect") && Ne("ucReconnect", [])
- }, this.requestHistory = function(e, t, n, i) {
- "undefined" == typeof n && (n = !1), "undefined" == typeof i && (i = 100), "undefined" == typeof t && (t = ""), oe("requestHistory") && Ne("requestHistory", [e, t, n, i])
- }, this.requestMUCHistory = function(e, t, n, i) {
- "undefined" == typeof n && (n = !1), "undefined" == typeof i && (i = 100), "undefined" == typeof t && (t = ""), oe("requestMUCHistory") && Ne("requestMUCHistory", [e, t, n, i])
- }, this.setSubject = function(e, t) {
- oe("setSubject") && Ne("setSubject", [e, t])
- }, this.sendMUCChatState = function(e, t) {
- oe("sendMUCChatState") && Ne("sendMUCChatState", [e, t])
- }, this.kickMUCUser = function(e, t, n) {
- oe("kickMUCUser") && Ne("kickMUCUser", [e, t, n])
- }, this.banMUCUser = function(e, t, n) {
- oe("banMUCUser") && Ne("banMUCUser", [e, t, n])
- }, this.unbanMUCUser = function(e, t, n) {
- oe("unbanMUCUser") && Ne("unbanMUCUser", [e, t, n])
- }, this.getVideoElementId = function(e) {
- var t = Q[e];
- return t ? t.getVideoElementId() : void ne("ERROR: No such call " + e)
- }, this.getAudioElementId = function(e) {
- var t = Q[e];
- return t ? t.getAudioElementId() : void ne("ERROR: No such call " + e)
- }, this.getStats = function(e, t) {
- var n = ee[e];
- n && n.getStats(t)
- };
- var ge, ve = function() {
- for (var e in ee) ee[e].close();
- ee = {}, Q = {}, te = 0, G && clearTimeout(G), B && clearTimeout(B)
- },
- ye = function(e) {
- x.onclose = null, ne("WS error: " + e);
- var t = z == a,
- n = t ? this.onConnectionClosed : this.onConnectionFailed;
- z = i, ve(), "function" == typeof n && n(e)
- }.bind(this),
- Se = function() {
- z = s, ne("WS connected")
- }.bind(this),
- Re = function() {
- ne("WS closed");
- var e = z == a,
- t = e ? this.onConnectionClosed : this.onConnectionFailed;
- z = i, ve(), "function" == typeof t && t("Connection closed")
- }.bind(this),
- Te = function() {
- G = null, Ne("__ping", []), B = setTimeout(function() {
- if (te > 0) return void p();
- B = null, ne("WS closed");
- var e = z == a,
- t = e ? this.onConnectionClosed : this.onConnectionFailed;
- z = i, ve(), "function" == typeof t && t("Connection closed")
- }.bind(this), w)
- }.bind(this),
- Ie = {},
- Ee = function(e, t) {
- var n = we(e, !1);
- n.start(t)
- },
- we = function(e, t) {
- BXIM.webrtc.phoneLog("createPeerConnection2 invoked"), ee[e] && ee[e].close();
- var n = new be(e, t);
- Q[e] && n.setStreamsActive(Q[e].streamsAreActive()), ee[e] = n, n.setLocalStream(Y), j && n.setScreenSharingStream(j);
- var i = Q[e];
- return i && (Q[e].setPeerConnection(n), n.setCall(i)), ee[e]
- },
- Me = null;
- ge = {
- __createPC: function(e, t) {
- !A || Y || "__default" == e ? Ee(e, t) : Ie[e] = t
- },
- __destroyPC: function(e) {
- ee[e] && (ee[e].close(), delete ee[e]), delete Ie[e]
- },
- __onPCStats: function(e, t) {
- ee[e] && "function" == typeof this.onNetStatsReceived && this.onNetStatsReceived(t)
- },
- __pong: function() {
- p()
- },
- __connectionSuccessful: function() {
- z == s && (z = a, "function" == typeof this.onConnectionEstablished && this.onConnectionEstablished(), G = setTimeout(Te, w))
- },
- loginSuccessful: function(e, t) {
- t && (Me = t.iceConfig), "function" == typeof this.onLoginSuccessful && this.onLoginSuccessful(e, t)
- },
- loginFailed: function(e, t) {
- "function" == typeof this.onLoginFailed && this.onLoginFailed({
- errorCode: e,
- oneTimeKey: t
- })
- },
- handleConnectionConnected: function(e, t, n) {
- var i = Q[e];
- if (i)
- if (i.canStartSendingCandidates(), i.getState() == c || i.getState() == r) {
- if (i.setState(l), "undefined" == typeof n);
- else {
- var o = i.getPeerConnection();
- o.onConnectionConnected(n)
- }
- "function" == typeof this.onCallConnected && this.onCallConnected(e, t)
- } else ne("WARNING: received handleConnectionConnected for call: " + e + " in invalid state: " + i.getState());
- else ne("WARNING: received handleConnectionConnected for unknown call: " + e)
- },
- stopRinging: function(e) {
- var t = Q[e];
- t ? (t.canStartSendingCandidates(), "function" == typeof this.onCallMediaStarted && this.onCallMediaStarted(e)) : ne("WARNING: received stopRinging for unknown call: " + e)
- },
- handleConnectionDisconnected: function(e, t) {
- var n = Q[e];
- n ? (n.setState(d), "function" == typeof this.onCallEnded && this.onCallEnded(e, t), fe(e)) : ne("WARNING: received handleConnectionDisconnected for unknown call: " + e)
- },
- handleConnectionFailed: function(e, t, n, i) {
- var o = Q[e];
- o ? o.getState() == c ? (o.setState(d), "function" == typeof this.onCallFailed && this.onCallFailed(e, t, n, i), fe(e)) : ne("WARNING: received handleConnectionFailed for call: " + e + " in invalid state: " + o.getState()) : ne("WARNING: received handleConnectionFailed for unknown call: " + e)
- },
- handleRingOut: function(e) {
- var t = Q[e];
- t ? (t.canStartSendingCandidates(), t.getState() == c ? "function" == typeof this.onCallRinging && this.onCallRinging(e) : ne("WARNING: received handleRingOut for call: " + e + " in invalid state: " + t.getState())) : ne("WARNING: received handleRingOut for unknown call: " + e)
- },
- handleIncomingConnection: function(e, t, n, i, o) {
- var s = new Pe(e, r, t, n);
- if (s.setHeaders(i), ue(s), de(i)) {
- var a = we(e, !0);
- a.onIncomingCall(o)
- } else ee[e] && s.setPeerConnection(ee[e]);
- "function" == typeof this.onIncomingCall ? this.onIncomingCall(e, t, n, i) : (this.rejectCall(e, 486), ne("WARNING: Received incoming call while no handler was specified"))
- },
- handleSIPInfo: function(e, t, n, i, o) {
- var s = Q[e];
- if (s)
- if (s.getState() == l || s.getState() == c || s.getState() == r)
- if ("application" == t && "zingaya-im" == n) "function" == typeof this.onInstantMessageReceived && this.onInstantMessageReceived(e, i);
- else if ("voximplant" == t && "sdpfrag" == n) {
- cands = JSON.parse(i);
- var a = s.getPeerConnection();
- for (var d in cands) a.addRemoteCandidate(cands[d][0], cands[d][1])
- } else if ("vi" == t && "sdpoffer" == n) {
- var a = s.getPeerConnection();
- a.setRemoteSDP(!0, i, o["X-ScreenStreamId"])
- } else if ("vi" == t && "sdpanswer" == n) {
- var a = s.getPeerConnection();
- a.setRemoteSDP(!1, i, o["X-ScreenStreamId"])
- } else "function" == typeof this.onSIPInfoReceived && this.onSIPInfoReceived(e, t + "/" + n, i, o);
- else ne("WARNING: received handleSIPInfo for call: " + e + " in invalid state: " + s.getState());
- else ne("WARNING: received handleSIPInfo for unknown call: " + e)
- },
- handleSipEvent: function() {},
- handleTransferStarted: function() {},
- handleTransferComplete: function(e) {
- var t = Q[e];
- t ? this.onTransferComplete && this.onTransferComplete(e) : ne("WARNING: received handleTransferComplete for unknown call: " + e)
- },
- handleTransferFailed: function(e) {
- var t = Q[e];
- t ? this.onTransferFailed && this.onTransferFailed(e) : ne("WARNING: received handleTransferFailed for unknown call: " + e)
- },
- handleRoster: function(e) {
- ie("handleRoster"), "function" == typeof this.onHandleRoster && this.onHandleRoster(e)
- },
- handleRosterItem: function(e, t, n, i, o) {
- ie("handleRosterItem id " + e + " resource " + n + " displayName " + i + " groups " + o), "function" == typeof this.onHandleRosterItem && this.onHandleRosterItem(e, t, n, i, o)
- },
- handleRosterPresence: function(e, t, n, i) {
- ie("handleRosterPresence"), "function" == typeof this.onHandleRosterPresence && this.onHandleRosterPresence(e, t, n, i)
- },
- handleMessage: function(e, t, n, i, o) {
- ie("handleMessage with id " + i + " from " + e + " to " + o + ": " + n), "function" == typeof this.onHandleMessage && this.onHandleMessage(e, t, n, i, o)
- },
- handleSelfPresence: function(e, t, n, i) {
- ie("handleSelfPresence from " + e + ": " + n), "function" == typeof this.onHandleSelfPresence && this.onHandleSelfPresence(e, t, n, i)
- },
- handleChatState: function(e, t, n) {
- ie("handleChatState from " + e + ": " + n), "function" == typeof this.onHandleChatState && this.onHandleChatState(e, t, n)
- },
- handleMessageEvent: function(e, t, n, i) {
- ie("handleMessageEvent from " + e + ": " + n), "function" == typeof this.onHandleMessageEvent && this.onHandleMessageEvent(e, t, n, i)
- },
- handleMessageModified: function(e, t, n, i) {
- ie("handleMessageModified message id " + t + " by " + e + " in chat with " + i + " msg " + n), "function" == typeof this.onHandleMessageModified && this.onHandleMessageModified(e, t, n, i)
- },
- handleMessageRemoved: function(e, t, n) {
- ie("handleMessageRemoved message id " + t + " by " + e + " in chat with " + n), "function" == typeof this.onHandleMessageRemoved && this.onHandleMessageRemoved(e, t, n)
- },
- handleSubscription: function(e, t, n, i) {
- ie("handleSubscription from " + e + ": " + n), "function" == typeof this.onHandleSubscription && this.onHandleSubscription(e, t, n, i)
- },
- onCallRemoteFunctionError: function(e, t, n, i) {
- ie("onCallRemoteFunctionError method " + e + " params " + t + " code " + n + " description " + i), "function" == typeof this.onCallRemoteFunctionError && this.onCallRemoteFunctionError(e, t, n, i)
- },
- handleError: function(e, t, n) {
- ie("handleError type " + e + " code " + t + " description " + n), "function" == typeof this.onIMError && this.onIMError(e, t, n)
- },
- handleUCConnected: function(e) {
- ie("handleUCConnected id " + e), "function" == typeof this.onUCConnected && this.onUCConnected(e)
- },
- handleUCDisconnected: function() {
- ie("handleUCDisconnected"), "function" == typeof this.onUCDisconnected && this.onUCDisconnected()
- },
- handleRosterError: function(e) {
- ie("handleRosterError code " + e), "function" == typeof this.onIMRosterError && this.onIMRosterError(e)
- },
- handleMUCError: function(e, t, n, i) {
- ie("handleMUCError room " + e + " operation " + t + " code " + n + " text " + i), "function" == typeof this.onMUCError && this.onMUCError(e, t, n, i)
- },
- handleMUCRoomCreation: function(e) {
- ie("handleMUCRoomCreation room " + e), "function" == typeof this.onMUCRoomCreation && this.onMUCRoomCreation(e)
- },
- handleMUCSubject: function(e, t, n, i) {
- ie("handleMUCSubject room " + e + " id " + t + " resource " + n + " subject " + i), "function" == typeof this.onMUCSubject && this.onMUCSubject(e, t, n, i)
- },
- handleMUCInfo: function(e, t, n, i) {
- ie("handleMUCInfo room " + e + " features " + t + " name " + n + " info " + i), "function" == typeof this.onMUCInfo && this.onMUCInfo(e, t, n, i)
- },
- handleMUCMessage: function(e, t, n, i, o, s, a) {
- ie("handleMUCMessage room " + e + " message_id " + n + " private " + t + " timestamp " + i + " from " + o + " resource " + s + " msg " + a), "function" == typeof this.onMUCMessage && this.onMUCMessage(e, n, t, i, o, s, a)
- },
- handleMUCInvitation: function(e, t, n, i, o, s) {
- ie("handleMUCInvitation room " + e + " from " + t + " reason " + n + " body " + i + " password " + o + " cont " + s), "function" == typeof this.onMUCInvitation && this.onMUCInvitation(e, t, n, i, o, s)
- },
- handleMUCInviteDecline: function(e, t, n) {
- ie("handleMUCInviteDecline room " + e + " invitee " + t + " reason " + n), "function" == typeof this.onMUCInviteDecline && this.onMUCInviteDecline(e, t, n)
- },
- handleMUCParticipantPresence: function(e, t, n, i) {
- ie("handleMUCParticipantPresence room " + e + " participant " + t + " presence " + n + " msg " + i), "function" == typeof this.onMUCParticipantPresence && this.onMUCParticipantPresence(e, t, n, i)
- },
- handleMUCParticipantJoin: function(e, t, n) {
- ie("handleMUCParticipantJoin room " + e + " participant " + t + " displayName " + n), "function" == typeof this.onMUCNewParticipant && this.onMUCNewParticipant(e, t, n)
- },
- handleMUCParticipantLeft: function(e, t) {
- ie("handleMUCParticipantLeft room " + e + " participant " + t), "function" == typeof this.onMUCParticipantExit && this.onMUCParticipantExit(e, t)
- },
- handleMUCRooms: function(e) {
- ie("handleMUCRooms rooms " + e), "function" == typeof this.onMUCRooms && this.onMUCRooms(e)
- },
- handleMUCParticipants: function(e, t) {
- ie("handleMUCParticipants room " + e + " list " + t), "function" == typeof this.onMUCParticipants && this.onMUCParticipants(e, t)
- },
- handleMUCBanList: function(e, t) {
- ie("handleMUCBanList room " + e + " list " + t), "function" == typeof this.onMUCBanList && this.onMUCBanList(e, t)
- },
- handleMUCHistory: function(e, t, n) {
- ie("handleMUCHistory room " + e + " mid " + t + " list " + n), "function" == typeof this.onMUCHistory && this.onMUCHistory(e, t, n)
- },
- handleMUCMessageModified: function(e, t, n, i, o, s, a) {
- ie("handleMUCMessageModified room " + e + " priv " + t + " mid " + n + " timestamp " + i + " from " + o + " resource " + s + " msg " + a), "function" == typeof this.onMUCMessageModified && this.onMUCMessageModified(e, t, n, i, o, s, a)
- },
- handleMUCMessageRemoved: function(e, t, n, i, o, s) {
- ie("handleMUCMessageRemoved room " + e + " priv " + t + " mid " + n + " timestamp " + i + " from " + o + " resource " + s), "function" == typeof this.onMUCMessageRemoved && this.onMUCMessageRemoved(e, t, n, i, o, s)
- },
- handleMUCChatState: function(e, t, n, i) {
- ie("handleMUCChatState room " + e + " from " + t + " resource " + n + " state " + i), "function" == typeof this.onMUCChatState && this.onMUCChatState(e, t, n, i)
- },
- handleHistory: function(e, t, n) {
- ie("handleHistory uri " + e + " mid " + t + " list " + n), "function" == typeof this.onHistory && this.onHistory(e, t, n)
- },
- handlePreFlightCheckResult: function(e, t, n) {
- this.onCheckComplete && this.onCheckComplete(e, t, n)
- },
- handleVoicemail: function(e) {
- this.onVoicemail && this.onVoicemail(e)
- },
- __connectionFailed: function() {
- z != i && this.disconnect()
- }
- };
- var Oe = function(e) {
- var t = JSON.parse(e.data),
- n = t.name,
- i = t.params;
- ie("Called local function " + n + " with params " + JSON.stringify(i)), "function" == typeof ge[n] ? ge[n].apply(this, i) : ne("Unknown function called: " + n), Ce()
- }.bind(this),
- Ae = function(e, t) {
- return "function" == typeof mozRTCSessionDescription ? new mozRTCSessionDescription({
- type: e,
- sdp: t
- }) : new RTCSessionDescription({
- type: e,
- sdp: t
- })
- },
- Pe = function(e, t, n, i) {
- var o, s, a = e,
- r = t,
- c = n,
- l = i,
- d = !0;
- this.id = function() {
- return a
- }, this.getRemoteParty = function() {
- return c
- }, this.getState = function() {
- return r
- }, this.setState = function(e) {
- r = e
- }, this.getDisplayName = function() {
- return l
- }, this.setPeerConnection = function(e) {
- BXIM.webrtc.phoneLog("Set peer connection: " + e), o = e
- }, this.getPeerConnection = function() {
- return BXIM.webrtc.phoneLog("Get peer connection: " + o), o
- }, this.setHeaders = function(e) {
- s = e
- }, this.getHeaders = function() {
- return s
- }, this.streamsAreActive = function() {
- return d
- }, this.setStreamsActive = function(e) {
- d = e, ee[a] && ee[a].setStreamsActive(e)
- }, this.getVideoElementId = function() {
- return o.getVideoElementId()
- }, this.getAudioElementId = function() {
- return o.getAudioElementId()
- }, this.canStartSendingCandidates = function() {
- o.canStartSendingCandidates()
- }, this.notifyICETimeout = function() {
- ce(a)
- }
- },
- be = function(t, n) {
- function i() {
- null === de && (de = setTimeout(function() {
- de = null, he.length > 0 && me(l, "voximplant", "sdpfrag", JSON.stringify(he), {}), he = []
- }, 100))
- }
- function o(e, t) {
- he.push([t, e]), ce && i()
- }
- var s = null,
- a = !1,
- r = null;
- n && (r = Me);
- var c = new g(r, {
- optional: [{
- DtlsSrtpKeyAgreement: "true"
- }]
- });
- S && (c.removeStream = function(e) {
- e.forEach(function(e) {
- c.removeTrack(e)
- })
- });
- var l = t,
- d = n;
- this.isDirect = function() {
- return d
- };
- var p, C = function(e) {
- ne("PC [" + l + "]: " + e)
- },
- R = function(e) {
- ie("PC [" + l + "]: " + e)
- },
- T = function(e) {
- ne("PC [" + l + "] ERROR: " + e)
- };
- this.setCall = function(e) {
- p = e
- }, this.getCall = function() {
- return p
- };
- var I, E, w = null;
- if (I = P(), I.id = "vi_audio_" + l, I.volume = q, document.body.appendChild(I), D) {
- E = N(), E.id = "vi_video_" + l, E.width = 400, E.height = 300, E.volume = q;
- var M = $ ? document.getElementById($) : document.body;
- M.appendChild(E)
- }
- var O = null,
- A = null,
- V = !1,
- x = !1,
- z = null,
- j = null,
- G = null,
- B = !1,
- J = !0,
- K = null,
- Z = function() {
- p && p.notifyICETimeout()
- }.bind(this);
- this.getStats = function(e) {
- G && z && c.getStats(function(e) {
- var t = e.result();
- for (var n in t) "ssrc" == t[n].type && (t[n].local == t[n] || !t[n].remote, t[n].remote == t[n] || !t[n].local)
- })
- }, this.getRemoteAudioStream = function() {
- return z
- }, this.getRemoteVideoStream = function() {
- return j
- }, this.getVideoElementId = function() {
- return E ? E.id : null
- }, this.getAudioElementId = function() {
- return I ? I.id : null
- }, this.setLocalStream = function(e) {
- if (!B && (G && (c.removeStream(S ? k : G), G = null), e)) {
- G = e; {
- "undefined" == typeof e.getAudioTracks ? e.audioTracks : e.getAudioTracks(), "undefined" == typeof e.getVideoTracks ? e.videoTracks : e.getVideoTracks()
- }
- G = e, S ? G.getTracks().forEach(function(e) {
- k.push(c.addTrack(e, G))
- }) : c.addStream(G), F(G.getAudioTracks(), !H), F(G.getVideoTracks(), X)
- }
- };
- var Y = function(e) {
- e && (K = e, c.addStream(K))
- };
- this.setScreenSharingStream = function(e) {
- K = e
- }, this.addScreenSharing = function(e) {
- B || (K && (c.removeStream(K), K = null), Y(e))
- }, this.onIncomingCall = function(e) {
- B || (O = Ae("offer", e), c.setRemoteDescription(O, function() {}, T))
- }, this.onConnectionConnected = function(e) {
- B || d && (O = Ae("answer", e), c.setRemoteDescription(O, function() {
- s = setTimeout(Z, h)
- }, T))
- }, this.outgoingCall = function() {
- B || c.createOffer(function(e) {
- f(e), A = e, c.setLocalDescription(Ae("offer", e.sdp), function() {
- Q()
- }, T)
- }, T)
- };
- var Q = function() {
- B || Ne("createCall", [-1, p.getRemoteParty(), !1, t, null, null, p.getHeaders(), "", A.sdp])
- };
- this.createAnswer = function() {
- B || (R("Calling createAnswer"), c.createAnswer(ee, T))
- };
- var ee = function(e) {
- B || (f(e), V = -1 != e.sdp.indexOf("a=rtcp-mux"), c.setLocalDescription(e, function() {
- A = e, x = !0, te()
- }, T))
- }.bind(this),
- te = function() {
- B || (s = setTimeout(Z, h), C("Sending local answer"), R("Local answer: " + A.sdp), d ? Ne("acceptCall", [l, le(p.getHeaders()), A.sdp]) : Ne("__confirmPC", [l, A.sdp]))
- },
- oe = !1,
- se = function() {
- oe || (oe = !0)
- },
- ce = !1,
- de = null,
- he = [],
- ue = null,
- fe = null,
- pe = null;
- this.canStartSendingCandidates = function() {
- ce = !0, i()
- }, this.addRemoteCandidate = function(e, t) {
- c.addIceCandidate(new v({
- candidate: t.substring(2),
- sdpMLineIndex: e
- }), function() {
- BXIM.webrtc.phoneLog("Added ice candidate")
- }, function(e) {
- R("error adding ice candidate " + e)
- })
- };
- var Ce = function(e) {
- if (!B)
- if (e.candidate) {
- R("ICE candidate: " + e.candidate.candidate);
- var t = e.candidate.candidate,
- n = t; - 1 == n.indexOf("a=") && (n = "a=" + n), y && A && (A.sdp += n, A.sdp += "\r\n"), d ? o(n, e.candidate.sdpMLineIndex) : Ne("__addCandidate", [l, n, e.candidate.sdpMLineIndex])
- } else C("End of candidates."), se()
- };
- this.setRemoteSDP = function(e, t, n) {
- "string" == typeof n && (ue = n), c.setRemoteDescription(Ae(e ? "offer" : "answer", t), function() {
- e ? c.createAnswer(function(e) {
- f(e), c.setLocalDescription(e, function() {
- me(l, "vi", "sdpanswer", e.sdp, null), a = !1
- }, function(e) {})
- }, function(e) {
- C("Error: " + e)
- }) : a = !1
- }, function(e) {
- C("Error: " + e)
- })
- };
- var ge = function() {
- return B ? void C("Renegotiation requested on closed PeerConnection") : null === A ? void C("Renegotiation needed, but no local SD, skipping") : "connected" != c.iceConnectionState && "completed" != c.iceConnectionState ? (C("Renegotiation requested while ice state is " + c.iceConnectionState + ". Postponing"), void setTimeout(ge, 100)) : a ? void C("Renegotiation in progress. Queueing") : (C("Renegotiation started"), a = !0, void(d ? c.createOffer(function(e) {
- f(e), C("New SDP: " + e.sdp), c.setLocalDescription(e, function() {
- var t = {};
- K && (t["X-ScreenStreamId"] = K.id), me(l, "vi", "sdpoffer", e.sdp, t)
- }, function(e) {
- C("Error: " + e)
- })
- }, function(e) {
- C("ERROR: " + e)
- }) : c.setRemoteDescription(O, function() {
- return B ? void(a = !1) : void c.createAnswer(function(e) {
- return B ? void(a = !1) : (f(e), A = e, void c.setLocalDescription(A, function() {
- a = !1, C("Renegotiation successful")
- }, function(e) {
- a = !1, C("ERROR: " + e)
- }))
- }, function(e) {
- a = !1, C("ERROR: " + e)
- })
- }, function(e) {
- a = !1, C("ERROR: " + e)
- })))
- },
- ve = function(t, n) {
- navigator.mozGetUserMedia ? t.getStats(null, function(e) {
- BXIM.webrtc.phoneLog(e);
- var t = [];
- e.forEach(function(e) {
- ("inboundrtp" == e.type || "outboundrtp" == e.type) && t.push(e)
- }), t.length > 0 && n(t)
- }, function(t) {
- C("ERROR: " + e)
- }) : t.getStats(function(e) {
- BXIM.webrtc.phoneLog(e);
- var t = [];
- e.result().forEach(function(e) {
- var n = {};
- e.names().forEach(function(t) {
- n[t] = e.stat(t)
- }), n.id = e.id, n.type = e.type, n.timestamp = e.timestamp, "ssrc" == n.type && t.push(n)
- }), n(t)
- })
- },
- ye = function(e) {
- var t = L(e.stream).length > 0,
- n = e.stream.id == ue;
- if (C("Remote stream added " + e.stream.id + " " + (t ? "video" : "audio")), n) {
- if (null == pe) {
- pe = N(), pe.id = "vi_ss_" + l, pe.width = 400, pe.height = 300, pe.volume = 0;
- var i = $ ? document.getElementById($) : document.body;
- i.appendChild(pe)
- }
- fe = e.stream, m(pe, e.stream), re(l, pe.id)
- } else t ? j = e.stream : z = e.stream, t ? E && m(E, e.stream) : m(I, e.stream), t || w || (w = setInterval(function() {
- ve(c, function(e) {
- ae(l, e)
- })
- }, u)), this.setStreamsActive(J)
- },
- Se = function(e) {},
- Re = function(e) {
- if ("stable" == c.signalingState && null != K) {
- var t = c.getLocalStreams();
- for (var n in t)
- if (t[n] == K) return;
- Y(K)
- }
- };
- this.setPlaybackVolume = function(e) {
- I && (I.volume = e), E && (E.volume = e)
- }, this.streamsAreActive = function() {
- return J
- }, this.setStreamsActive = function(e) {
- J = e, F(_(z), e && !W), F(_(j), e && !W), F(L(j), e), Ne("__muteLocal", [l, !e])
- }.bind(this), this.updateMicrophoneMuteState = function() {}, this.updateSpeakerMuteState = function() {
- z && F(_(z), J && !W)
- }, this.activateStreams = function() {
- B || this.setStreamsActive(!0)
- }, this.deactivateStreams = function() {
- B || this.setStreamsActive(!1)
- }, c.onicecandidate = Ce.bind(this), c.onaddstream = ye.bind(this), c.onnegotiationneeded = ge.bind(this), c.onremovestream = Se.bind(this), c.onsignalingstatechange = Re.bind(this), c.oniceconnectionstatechange = function() {
- ("completed" == c.iceConnectionState || "connected" == c.iceConnectionState && s) && (clearTimeout(s), s = null)
- }.bind(this), this.close = function() {
- B = !0, w && clearInterval(w), w = null, c.close(), I && (I.parentNode.removeChild(I),
- b(I)), E && (E.parentNode.removeChild(E), U(E)), pe && (pe.parentNode.removeChild(pe), U(pe))
- }, this.start = function(e) {
- B || (O = Ae("offer", e), c.setRemoteDescription(O, function() {
- c.createAnswer(function(e) {
- f(e), BXIM.webrtc.phoneLog("Local answer created: " + e.sdp), V = -1 != e.sdp.indexOf("a=rtcp-mux"), c.setLocalDescription(e, function() {
- A = e, x = !0, te()
- }, T)
- }, T)
- }, T))
- }
- },
- Ne = function(e, t) {
- ie("Called remote function " + e + " with params " + JSON.stringify(t)), x ? x.send(JSON.stringify({
- name: e,
- params: t
- })) : ne("ERROR: can't call remote function when not connected"), Ce()
- }
- }
- }(i), function(e, t) {
- e.Config = {}, e.FlashVideoSettings = {}, e.VideoSettings = {}, e.AudioSourceInfo = {}, e.VideoSourceInfo = {}, e.AudioOutputInfo = {}, e.NetworkInfo = {}, e.SubscriptionRequestType = {
- Subscribe: 0,
- Unsubscribe: 1
- }, e.ChatStateType = {
- Active: 1,
- Composing: 2,
- Paused: 4,
- Inactive: 8,
- Gone: 16,
- Invalid: 32
- }, e.MessageEventType = {
- Offline: 1,
- Delivered: 2,
- Displayed: 4,
- Composing: 8,
- Invalid: 16,
- Cancel: 32
- }, e.RosterItemEvent = {
- Added: 0,
- Removed: 1,
- Updated: 2,
- Subscribed: 3,
- Unsubscribed: 4
- }, e.UserStatuses = {
- Online: 0,
- Chat: 1,
- Away: 2,
- DND: 3,
- XA: 4,
- Offline: 5
- }, e.OperatorACDStatuses = {
- Offline: "OFFLINE",
- Online: "ONLINE",
- Ready: "READY",
- InService: "IN_SERVICE",
- AfterService: "AFTER_SERVICE",
- Timeout: "TIMEOUT",
- DND: "DND"
- }, e.IMErrorType = {
- RemoteFunctionError: "RemoteFunctionError",
- Error: "Error",
- RosterError: "RosterError"
- }, e.LoginOptions = {}, e.RosterItem = {}, e.ChatRoom = {}, e.ChatRoomInfo = {}, e.ChatRoomParticipant = {}, e.ParticipantInfo = {}, e.IMHistoryMessage = {}
- }(i), function(e, t) {
- e.Events = {
- SDKReady: "SDKReady",
- ConnectionEstablished: "ConnectionEstablished",
- ConnectionFailed: "ConnectionFailed",
- ConnectionClosed: "ConnectionClosed",
- AuthResult: "AuthResult",
- PlaybackFinished: "PlaybackFinished",
- MicAccessResult: "MicAccessResult",
- IncomingCall: "IncomingCall",
- SourcesInfoUpdated: "SourcesInfoUpdated",
- NetStatsReceived: "NetStatsReceived"
- }, e.CallEvents = {
- Connected: "Connected",
- Disconnected: "Disconnected",
- Failed: "Failed",
- ProgressToneStart: "ProgressToneStart",
- ProgressToneStop: "ProgressToneStop",
- MessageReceived: "MessageReceived",
- InfoReceived: "InfoReceived",
- TransferComplete: "TransferComplete",
- TransferFailed: "TransferFailed",
- RemoteScreenCaptureStarted: "RemoteScreenCaptureStarted",
- ICETimeout: "ICETimeout",
- RTCStatsReceived: "RTCStatsReceived"
- }, e.IMEvents = {
- RosterReceived: "RosterReceived",
- RosterItemChange: "RosterItemChange",
- RosterPresenceUpdate: "RosterPresenceUpdate",
- PresenceUpdate: "PresenceUpdate",
- MessageReceived: "MessageReceived",
- MessageModified: "MessageModified",
- MessageRemoved: "MessageRemoved",
- ChatStateUpdate: "ChatStateUpdate",
- MessageStatus: "MessageStatus",
- SubscriptionRequest: "SubscriptionRequest",
- ChatHistoryReceived: "ChatHistoryReceived",
- ChatRoomCreated: "ChatRoomCreated",
- ChatRoomSubjectChange: "ChatRoomSubjectChange",
- ChatRoomInfo: "ChatRoomInfo",
- ChatRoomMessageReceived: "ChatRoomMessageReceived",
- ChatRoomInvitation: "ChatRoomInvitation",
- ChatRoomInviteDeclined: "ChatRoomInviteDeclined",
- ChatRoomPresenceUpdate: "ChatRoomPresenceUpdate",
- ChatRoomNewParticipant: "ChatRoomNewParticipant",
- ChatRoomParticipantExit: "ChatRoomParticipantExit",
- ChatRoomsDataReceived: "ChatRoomsDataReceived",
- ChatRoomParticipants: "ChatRoomParticipants",
- ChatRoomBanList: "ChatRoomBanList",
- ChatRoomHistoryReceived: "ChatRoomHistoryReceived",
- ChatRoomMessageModified: "ChatRoomMessageModified",
- ChatRoomMessageRemoved: "ChatRoomMessageRemoved",
- ChatRoomStateUpdate: "ChatRoomStateUpdate",
- ChatRoomError: "ChatRoomError",
- SystemError: "IMError",
- UCConnected: "UCConnected",
- UCDisconnected: "UCDisconnected"
- }
- }(i), function(e, t) {
- e.Call = function(e, t, n, i, o, s) {
- var a = o,
- r = e,
- c = t,
- l = n,
- d = i,
- h = s;
- this.eventListeners = {}, this.call = function(e) {
- return "undefined" == typeof e ? r : void(r = e)
- }, this.__number = function(e) {
- return "undefined" == typeof e ? c : void(c = e)
- }, this.__displayName = function() {
- return l
- }, this.__headers = function() {
- return d
- }, this.RTC = function() {
- return a
- }, this.zingayaAPI = function() {
- return h
- }
- }, e.Call.prototype = {
- id: function() {
- return this.call()
- },
- number: function() {
- return this.__number()
- },
- displayName: function() {
- return this.__displayName()
- },
- headers: function() {
- return this.__headers()
- },
- active: function() {
- return this.RTC() ? this.zingayaAPI().isCallActive(this.call()) : e.Utils.swfMovie("voximplantSWF").isCallActive(this.call())
- },
- state: function() {
- if (this.RTC()) return this.zingayaAPI().getCallState(this.call());
- var t = e.Utils.swfMovie("voximplantSWF").getCallState(this.call()).toUpperCase();
- switch (t) {
- case "CONNECTING":
- t = e.VI_CALL_STATE_ALERTING;
- break;
- case "CONNECTED_ON_HOLD":
- t = e.VI_CALL_STATE_CONNECTED;
- break;
- case "DISCONNECTED":
- case "FAILED":
- t = e.VI_CALL_STATE_ENDED
- }
- return t
- },
- answer: function(t, n) {
- if ("undefined" != typeof t && ("undefined" == typeof n && (n = {}), n["VI-CallData"] = t), this.RTC()) {
- if (this.zingayaAPI().getCallState(this.call()) != e.VI_CALL_STATE_ALERTING) throw new Error("NO_INCOMING_CALL");
- this.zingayaAPI().answerCall(this.call(), n)
- } else n = JSON.stringify(n), BXIM.webrtc.phoneLog("Accepting call, id " + this.call()), e.Utils.swfMovie("voximplantSWF").accept(this.call(), n)
- },
- decline: function(t) {
- if (this.RTC()) {
- if (this.zingayaAPI().getCallState(this.call()) != e.VI_CALL_STATE_ALERTING) throw new Error("NO_INCOMING_CALL");
- this.zingayaAPI().rejectCall(this.call(), 486, t)
- } else t = e.Utils.stringifyExtraHeaders(t), e.Utils.swfMovie("voximplantSWF").reject(this.call(), t)
- },
- reject: function(e) {
- this.decline(e)
- },
- hangup: function(t) {
- if (this.RTC()) {
- if (this.zingayaAPI().getCallState(this.call()) != e.VI_CALL_STATE_CONNECTED && this.zingayaAPI().getCallState(this.call()) != e.VI_CALL_STATE_PROGRESSING) throw new Error("WRONG_CALL_STATE");
- this.zingayaAPI().hangupCall(this.call(), t)
- } else t = e.Utils.stringifyExtraHeaders(t), e.Utils.swfMovie("voximplantSWF").disconnectCall(this.call(), t)
- },
- sendTone: function(t) {
- if ("*" == t) t = 10;
- else if ("#" == t) t = 11;
- else if (t = parseInt(t), 0 > t || t > 9) throw new Error("WRONG_TONE_INPUT");
- if (this.RTC()) {
- if (this.zingayaAPI().getCallState(this.call()) != e.VI_CALL_STATE_CONNECTED) throw new Error("CALL_NOT_CONNECTED");
- this.zingayaAPI().sendDigit(this.call(), t)
- } else e.Utils.swfMovie("voximplantSWF").sendDTMF(t, this.call())
- },
- mutePlayback: function() {
- this.RTC() ? this.zingayaAPI().mutePlayback(!0) : e.Utils.swfMovie("voximplantSWF").muteIncomingAudio(this.call())
- },
- muteMicrophone: function() {
- this.RTC() ? this.zingayaAPI().muteMicrophone(!0) : e.Utils.swfMovie("voximplantSWF").muteOutgoingAudio(this.call())
- },
- unmutePlayback: function() {
- this.RTC() ? this.zingayaAPI().mutePlayback(!1) : e.Utils.swfMovie("voximplantSWF").unmuteIncomingAudio(this.call())
- },
- unmuteMicrophone: function() {
- this.RTC() ? this.zingayaAPI().muteMicrophone(!1) : e.Utils.swfMovie("voximplantSWF").unmuteOutgoingAudio(this.call())
- },
- sendVideo: function(e) {},
- showRemoteVideo: function(t) {
- "undefined" == typeof t && (t = !0), this.RTC() ? document.getElementById(this.zingayaAPI().getVideoElementId(this.call())).style.display = t ? "block" : "none" : e.Utils.swfMovie("voximplantSWF").showRemoteVideo(this.call(), t)
- },
- setRemoteVideoPosition: function(t, n) {
- if (this.RTC()) throw new Error("Please use CSS to position '#voximplantcontainer' element");
- e.Utils.swfMovie("voximplantSWF").setRemoteViewPosition(this.call(), t, n)
- },
- setRemoteVideoSize: function(t, n) {
- if (this.RTC()) throw new Error("Please use CSS to set size of '#voximplantcontainer' element");
- e.Utils.swfMovie("voximplantSWF").setRemoteViewSize(this.call(), t, n)
- },
- sendInfo: function(t, n, i) {
- var o, s, a = t.indexOf("/");
- if (-1 == a ? (o = "application", s = t) : (o = t.substring(0, a), s = t.substring(a + 1)), this.RTC()) {
- if (this.zingayaAPI().getCallState(this.call()) != e.VI_CALL_STATE_CONNECTED) throw new Error("CALL_NOT_CONNECTED");
- this.zingayaAPI().sendSIPInfo(this.call(), o, s, n, i)
- } else i = e.Utils.stringifyExtraHeaders(i), e.Utils.swfMovie("voximplantSWF").sendSIPInfo(this.call(), o, s, n, i)
- },
- sendMessage: function(t) {
- if (this.RTC()) {
- if (this.zingayaAPI().getCallState(this.call()) != e.VI_CALL_STATE_CONNECTED) throw new Error("CALL_NOT_CONNECTED");
- this.zingayaAPI().sendInstantMessage(this.call(), t)
- } else e.Utils.swfMovie("voximplantSWF").sendMessage(this.call(), t)
- },
- setVideoSettings: function(t, n, i) {
- this.RTC() ? this.zingayaAPI().setConstraints(t, n, i, !0) : this.useRTCOnly || ("[object Object]" == Object.prototype.toString.call(t) && (t = JSON.stringify(t)), e.Utils.swfMovie("voximplantSWF").setVideoSettings(t, this.call()))
- },
- getIncomingStreamInfo: function() {
- if (this.RTC());
- else if (!this.useRTCOnly) return JSON.parse(e.Utils.swfMovie("voximplantSWF").getIncomingStreamInfo(this.call()))
- },
- getOutgoingStreamInfo: function() {
- if (this.RTC());
- else if (!this.useRTCOnly) return JSON.parse(e.Utils.swfMovie("voximplantSWF").getOutgoingStreamInfo(this.call()))
- },
- getVideoElementId: function() {
- return this.RTC() ? this.zingayaAPI().getVideoElementId(this.call()) : void 0
- },
- useAudioOutput: function(e) {
- if (this.RTC()) {
- var t = this.zingayaAPI().getVideoElementId(this.call()),
- n = this.zingayaAPI().getAudioElementId(this.call());
- document.getElementById(n).currentTime > 0 ? document.getElementById(n).setSinkId(e) : document.getElementById(t).currentTime > 0 && document.getElementById(t).setSinkId(e)
- }
- }
- }, e.Call.prototype.addEventListener = function(e, t) {
- "undefined" == typeof this.eventListeners[e] && (this.eventListeners[e] = []), this.eventListeners[e].push(t)
- }, e.Call.prototype.removeEventListener = function(e, t) {
- if ("undefined" != typeof this.eventListeners[e])
- for (var n = 0; n < this.eventListeners[e].length; n++)
- if (this.eventListeners[e][n] == t) {
- this.eventListeners[e].splice(n, 1);
- break
- }
- }
- }(i), function(e, t) {
- e.Client = function() {
- this.config = null, this.calls = [];
- var n = e.Call;
- delete e.Call;
- var i = !1;
- this.eventListeners = {}, this.progressToneScript = {
- US: "440@-19,480@-19;*(2/4/1+2)",
- RU: "425@-19;*(1/3/1)"
- }, this.playingNow = !1, this.serversList = [];
- var o = 100;
- this.audioSourcesList = [], this.videoSourcesList = [], this.audioOutputsList = [], this.deviceEnumAPI = function() {
- navigator.mediaDevices && navigator.mediaDevices.enumerateDevices ? navigator.mediaDevices.enumerateDevices().then(this.gotSources) : "undefined" != typeof MediaStreamTrack && "undefined" != typeof MediaStreamTrack.getSources && MediaStreamTrack.getSources(this.gotSources)
- }, this.gotSources = function(e) {
- 0 !== this.audioSourcesList.length && (this.audioSourcesList = []), 0 !== this.videoSourcesList.length && (this.videoSourcesList = []), 0 !== this.audioOutputsList.length && (this.audioOutputsList = []);
- for (var t = 0, n = 0, i = 0, o = 0; o != e.length; ++o) {
- var s = e[o];
- "audio" === s.kind || "audioinput" === s.kind ? (n++, this.audioSourcesList.push({
- id: s.id || s.deviceId,
- name: s.label || "Audio recording device " + n
- })) : "video" === s.kind || "videoinput" === s.kind ? (t++, this.videoSourcesList.push({
- id: s.id || s.deviceId,
- name: s.label || "Video recording device " + t
- })) : "audiooutput" === s.kind && (i++, this.audioOutputsList.push({
- id: s.id || s.deviceId,
- name: s.label || "Audio playback device " + i
- }))
- }
- this.dispatchEvent({
- name: "SourcesInfoUpdated"
- })
- }.bind(this), this.__init = function(i) {
- function o() {
- if (this.dispatchEvent({
- name: "SDKReady",
- version: e.version
- }), -1 != navigator.userAgent.indexOf("Safari")) {
- var t = document.getElementById(this.swfContainer);
- null !== t && (t.style.minWidth = t.style.width = "215px")
- }
- for (var n = JSON.parse(e.Utils.swfMovie("voximplantSWF").audioSources()), i = JSON.parse(e.Utils.swfMovie("voximplantSWF").videoSources()), o = 0; o < n.length; o++) this.audioSourcesList.push({
- id: o,
- name: n[o]
- });
- for (o = 0; o < i.length; o++) this.videoSourcesList.push({
- id: o,
- name: i[o]
- });
- this.dispatchEvent({
- name: "SourcesInfoUpdated"
- })
- }
- if (null !== this.config) throw "VoxImplant.Client has been already initialized";
- if (this.config = "undefined" != typeof i ? i : {}, this.useFlashOnly = this.config.useFlashOnly === !0 ? !0 : !1, this.useRTCOnly = this.config.useRTCOnly === !0 ? !0 : !1, this.RTCsupported = !1, this.micRequired = this.config.micRequired !== !1 ? !0 : !1, this.videoSupport = this.config.videoSupport !== !0 ? !1 : !0, this.videoConstraints = "undefined" != typeof this.config.videoConstraints ? this.config.videoConstraints : null, this.swfContainer = "undefined" != typeof this.config.swfContainer ? this.config.swfContainer : null, this.progressToneCountry = "undefined" != typeof this.config.progressToneCountry ? this.config.progressToneCountry : "US", this.progressTone = this.config.progressTone !== !0 ? !1 : !0, this.showFlashSettings = this.config.showFlashSettings === !0 ? !0 : !1, "undefined" != typeof this.config.serverIp && (this.serverIp = this.config.serverIp), "undefined" != typeof this.config.swfURL && (this.swfURL = this.config.swfURL), this.showDebugInfo = BXIM.webrtc.debug, this.imXSSprotection = "undefined" != typeof this.config.imXSSprotection ? this.config.imXSSprotection : !0, this.imAutoReconnect = "undefined" != typeof this.config.imAutoReconnect ? this.config.imAutoReconnect : !0, this.imReconnectInterval = "undefined" != typeof this.config.imReconnectInterval ? this.config.imReconnectInterval >= 2e3 ? this.config.imReconnectInterval : 2e3 : 3e3, this.imReconnectTs = 0, this.showWarnings = this.config.showWarnings !== !1 ? !0 : !1, "127.0.0.1" != window.location.hostname && "localhost" != window.location.hostname && "https:" != window.location.protocol && "undefined" != typeof console.error && this.showWarnings && console.error("WARNING: getUserMedia() is deprecated on insecure origins, and support will be removed in the future. You should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details."), "undefined" != typeof webkitRTCPeerConnection || "undefined" != typeof mozRTCPeerConnection || "undefined" != typeof RTCPeerConnection)
- if ("undefined" != typeof mozRTCPeerConnection) try {
- {
- new mozRTCPeerConnection({
- iceServers: []
- })
- }
- this.RTCsupported = !0
- } catch (s) {} else this.RTCsupported = !0;
- var a;
- if (this.RTCsupported && !this.useFlashOnly) null != window.location.href.match(/^file\:\/{3}.*$/g) && "undefined" != typeof console.error && this.showWarnings && console.error("WebRTC requires application to be loaded from a web server"), this.zingayaAPI = new e.ZingayaAPI(this.videoSupport, this.micRequired), delete e.ZingayaAPI, this.zingayaAPI.onConnectionEstablished = function() {
- this.connectionState(!0), this.dispatchEvent({
- name: "ConnectionEstablished"
- })
- }.bind(this), this.zingayaAPI.onConnectionFailed = function(e) {
- this.connectionState(!1), this.serversList.length > 1 && "undefined" == typeof this.serverIp ? (this.serversList.splice(0, 1), this.connectTo(this.serversList[0], !0)) : this.dispatchEvent({
- name: "ConnectionFailed",
- message: e
- })
- }.bind(this), this.zingayaAPI.onConnectionClosed = function() {
- this.connectionState(!1), this.__cleanup(), this.dispatchEvent({
- name: "ConnectionClosed"
- }), this.progressTone && this.stopProgressTone()
- }.bind(this), this.zingayaAPI.onLoginSuccessful = function(e, t) {
- this.dispatchEvent({
- name: "AuthResult",
- result: !0,
- displayName: e,
- options: t
- })
- }.bind(this), this.zingayaAPI.onLoginFailed = function(e) {
- this.dispatchEvent({
- name: "AuthResult",
- result: !1,
- code: e.errorCode,
- key: e.oneTimeKey
- })
- }.bind(this), this.zingayaAPI.onCallConnected = function(e, t) {
- this.getCall(e).dispatchEvent({
- name: "Connected",
- call: this.getCall(e),
- headers: t
- }), this.progressTone && this.stopProgressTone()
- }.bind(this), this.zingayaAPI.onCallEnded = function(e, t) {
- this.getCall(e).dispatchEvent({
- name: "Disconnected",
- call: this.getCall(e),
- headers: t
- }), this.removeCall(e), this.progressTone && this.stopProgressTone()
- }.bind(this), this.zingayaAPI.onCallFailed = function(e, t, n, i) {
- this.getCall(e).dispatchEvent({
- name: "Failed",
- call: this.getCall(e),
- code: t,
- reason: n,
- headers: i
- }), this.removeCall(e), this.progressTone && this.stopProgressTone()
- }.bind(this), this.zingayaAPI.onMediaAccessGranted = function() {
- this.deviceEnumAPI(), this.micRequired && this.zingayaAPI.connectTo(this.host, "platform"), this.dispatchEvent({
- name: "MicAccessResult",
- result: !0
- })
- }.bind(this), this.zingayaAPI.onMediaAccessRejected = function(e) {
- this.dispatchEvent({
- name: "MicAccessResult",
- result: !1,
- reason: e
- })
- }.bind(this), this.zingayaAPI.onIncomingCall = function(e, t, i, o) {
- var s = new n(e, t, i, o, !0, this.zingayaAPI);
- this.calls.length > 0 && this.zingayaAPI.setCallActive(e, !1), this.calls.push(s), this.dispatchEvent({
- name: "IncomingCall",
- call: s,
- headers: o
- })
- }.bind(this), this.zingayaAPI.onCallRinging = function(e) {
- this.getCall(e).dispatchEvent({
- name: "ProgressToneStart",
- call: this.getCall(e)
- }), this.progressTone && this.playProgressTone()
- }.bind(this), this.zingayaAPI.onCallMediaStarted = function(e) {
- this.getCall(e).dispatchEvent({
- name: "ProgressToneStop",
- call: this.getCall(e)
- }), this.progressTone && this.stopProgressTone()
- }.bind(this), this.zingayaAPI.onRemoteScreenCaptureStarted = function(e, t) {
- this.getCall(e).dispatchEvent({
- name: "RemoteScreenCaptureStarted",
- call: this.getCall(e),
- videoElementId: t
- })
- }.bind(this), this.zingayaAPI.onInstantMessageReceived = function(e, t) {
- this.getCall(e).dispatchEvent({
- name: "MessageReceived",
- call: this.getCall(e),
- text: t
- })
- }.bind(this), this.zingayaAPI.onSIPInfoReceived = function(e, t, n, i) {
- this.getCall(e).dispatchEvent({
- name: "InfoReceived",
- call: this.getCall(e),
- mimeType: t,
- body: n,
- headers: i
- })
- }.bind(this), this.zingayaAPI.onTransferComplete = function(e) {
- this.getCall(e).dispatchEvent({
- name: "TransferComplete",
- call: this.getCall(e)
- })
- }.bind(this), this.zingayaAPI.onTransferFailed = function(e) {
- this.getCall(e).dispatchEvent({
- name: "TransferFailed",
- call: this.getCall(e)
- })
- }.bind(this), this.zingayaAPI.onNetStatsReceived = function(e) {
- this.dispatchEvent({
- name: "NetStatsReceived",
- stats: e
- })
- }.bind(this), this.zingayaAPI.onRTCStatsCollected = function(e, t) {
- null != this.getCall(e) && this.getCall(e).dispatchEvent({
- name: "RTCStatsReceived",
- stats: t
- })
- }.bind(this), this.zingayaAPI.onHandleRoster = function(e) {
- this.dispatchEvent({
- name: "RosterReceived",
- roster: e
- })
- }.bind(this), this.zingayaAPI.onHandleRosterItem = function(e, t, n, i, o) {
- this.dispatchEvent({
- name: "RosterItemChange",
- id: e,
- resource: t,
- type: n,
- displayName: i,
- groups: o
- })
- }.bind(this), this.zingayaAPI.onHandleRosterPresence = function(e, t, n, i) {
- this.dispatchEvent({
- name: "RosterPresenceUpdate",
- id: e,
- resource: t,
- presence: n,
- message: i
- })
- }.bind(this), this.zingayaAPI.onHandleMessage = function(t, n, i, o, s) {
- this.imXSSprotection && (i = e.Utils.filterXSS(i)), this.dispatchEvent({
- name: "MessageReceived",
- id: t,
- resource: n,
- content: i,
- message_id: o,
- to: s
- })
- }.bind(this), this.zingayaAPI.onHandleSelfPresence = function(e, t, n, i) {
- this.dispatchEvent({
- name: "PresenceUpdate",
- id: e,
- resource: t,
- presence: n,
- message: i
- })
- }.bind(this), this.zingayaAPI.onHandleChatState = function(e, t, n) {
- this.dispatchEvent({
- name: "ChatStateUpdate",
- id: e,
- resource: t,
- state: n
- })
- }.bind(this), this.zingayaAPI.onHandleMessageEvent = function(e, t, n, i) {
- this.dispatchEvent({
- name: "MessageStatus",
- id: e,
- resource: t,
- type: n,
- message_id: i
- })
- }.bind(this), this.zingayaAPI.onHandleMessageModified = function(t, n, i, o) {
- this.imXSSprotection && (i = e.Utils.filterXSS(i)), this.dispatchEvent({
- name: "MessageModified",
- id: t,
- message_id: n,
- content: i,
- to: o
- })
- }.bind(this), this.zingayaAPI.onHandleMessageRemoved = function(e, t, n) {
- this.dispatchEvent({
- name: "MessageRemoved",
- id: e,
- message_id: t,
- to: n
- })
- }.bind(this), this.zingayaAPI.onHandleSubscription = function(e, t, n, i) {
- this.dispatchEvent({
- name: "SubscriptionRequest",
- id: e,
- resource: t,
- type: n,
- message: i
- })
- }.bind(this), this.zingayaAPI.onCallRemoteFunctionError = function(e, t, n, i) {
- this.dispatchEvent({
- name: "IMError",
- errorType: "RemoteFunctionError",
- errorData: {
- method: e,
- params: t,
- code: n,
- description: i
- }
- })
- }.bind(this), this.zingayaAPI.onIMError = function(e, t, n) {
- this.dispatchEvent({
- name: "IMError",
- errorType: "Error",
- errorData: {
- type: e,
- code: t,
- description: n
- }
- })
- }.bind(this), this.zingayaAPI.onUCConnected = function(e) {
- this.imAutoReconnect === !0 && clearInterval(this.imReconnectTs), this.dispatchEvent({
- name: "UCConnected",
- id: e
- })
- }.bind(this), this.zingayaAPI.onUCDisconnected = function() {
- this.imAutoReconnect === !0 && (clearInterval(this.imReconnectTs), this.imReconnectTs = setInterval(function() {
- this.zingayaAPI.ucReconnect()
- }.bind(this), this.imReconnectInterval)), this.dispatchEvent({
- name: "UCDisconnected"
- })
- }.bind(this), this.zingayaAPI.onIMRosterError = function(e) {
- this.dispatchEvent({
- name: "IMError",
- errorType: "RosterError",
- errorData: {
- code: e
- }
- })
- }.bind(this), this.zingayaAPI.onMUCError = function(e, t, n, i) {
- this.dispatchEvent({
- name: "ChatRoomError",
- room: e,
- operation: t,
- code: n,
- text: i
- })
- }.bind(this), this.zingayaAPI.onMUCRoomCreation = function(e) {
- this.dispatchEvent({
- name: "ChatRoomCreated",
- room: e
- })
- }.bind(this), this.zingayaAPI.onMUCSubject = function(e, t, n, i) {
- this.dispatchEvent({
- name: "ChatRoomSubjectChange",
- room: e,
- id: t,
- resource: n,
- subject: i
- })
- }.bind(this), this.zingayaAPI.onMUCInfo = function(e, t, n, i) {
- this.dispatchEvent({
- name: "ChatRoomInfo",
- room: e,
- features: t,
- room_name: n,
- info: i
- })
- }.bind(this), this.zingayaAPI.onMUCMessage = function(t, n, i, o, s, a, r) {
- this.imXSSprotection && (r = e.Utils.filterXSS(r)), this.dispatchEvent({
- name: "ChatRoomMessageReceived",
- room: t,
- message_id: n,
- private_message: i,
- timestamp: o,
- from: s,
- resource: a,
- content: r
- })
- }.bind(this), this.zingayaAPI.onMUCInvitation = function(e, t, n, i, o, s) {
- this.dispatchEvent({
- name: "ChatRoomInvitation",
- room: e,
- from: t,
- reason: n,
- body: i,
- password: o,
- cont: s
- })
- }.bind(this), this.zingayaAPI.onMUCInviteDecline = function(e, t, n) {
- this.dispatchEvent({
- name: "ChatRoomInviteDeclined",
- room: e,
- invitee: t,
- reason: n
- })
- }.bind(this), this.zingayaAPI.onMUCParticipantPresence = function(e, t, n, i) {
- this.dispatchEvent({
- name: "ChatRoomPresenceUpdate",
- room: e,
- participant: t,
- presence: n,
- message: i
- })
- }.bind(this), this.zingayaAPI.onMUCNewParticipant = function(e, t, n) {
- this.dispatchEvent({
- name: "ChatRoomNewParticipant",
- room: e,
- participant: t,
- displayName: n
- })
- }.bind(this), this.zingayaAPI.onMUCParticipantExit = function(e, t) {
- this.dispatchEvent({
- name: "ChatRoomParticipantExit",
- room: e,
- participant: t
- })
- }.bind(this), this.zingayaAPI.onMUCRooms = function(e) {
- this.dispatchEvent({
- name: "ChatRoomsDataReceived",
- rooms: e
- })
- }.bind(this), this.zingayaAPI.onMUCParticipants = function(e, t) {
- this.dispatchEvent({
- name: "ChatRoomParticipants",
- room: e,
- participants: t
- })
- }.bind(this), this.zingayaAPI.onMUCBanList = function(e, t) {
- this.dispatchEvent({
- name: "ChatRoomBanList",
- room: e,
- participants: t
- })
- }.bind(this), this.zingayaAPI.onMUCHistory = function(t, n, i) {
- this.imXSSprotection && i.forEach(function(t) {
- t.body = e.Utils.filterXSS(t.body)
- }), this.dispatchEvent({
- name: "ChatRoomHistoryReceived",
- room: t,
- message_id: n,
- messages: i
- })
- }.bind(this), this.zingayaAPI.onMUCMessageModified = function(t, n, i, o, s, a, r) {
- this.imXSSprotection && (r = e.Utils.filterXSS(r)), this.dispatchEvent({
- name: "ChatRoomMessageModified",
- room: t,
- private_message: n,
- message_id: i,
- timestamp: o,
- from: s,
- resource: a,
- content: r
- })
- }.bind(this), this.zingayaAPI.onMUCMessageRemoved = function(e, t, n, i, o, s) {
- this.dispatchEvent({
- name: "ChatRoomMessageRemoved",
- room: e,
- private_message: t,
- message_id: n,
- timestamp: i,
- from: o,
- resource: s
- })
- }.bind(this), this.zingayaAPI.onMUCChatState = function(e, t, n, i) {
- this.dispatchEvent({
- name: "ChatRoomStateUpdate",
- room: e,
- from: t,
- resource: n,
- state: i
- })
- }.bind(this), this.zingayaAPI.onHistory = function(t, n, i) {
- this.imXSSprotection && i.forEach(function(t) {
- t.body = e.Utils.filterXSS(t.body)
- }), this.dispatchEvent({
- name: "ChatHistoryReceived",
- id: t,
- message_id: n,
- messages: i
- })
- }.bind(this), this.zingayaAPI.onCallICETimeout = function(e) {
- this.getCall(e).dispatchEvent({
- name: "ICETimeout",
- call: this.getCall(e)
- })
- }.bind(this), this.zingayaAPI.writeLog = function(e) {
- if ("function" == typeof this.writeLog) this.writeLog(e);
- else {
- var t = {
- year: "numeric",
- month: "numeric",
- day: "numeric"
- };
- this.showDebugInfo && BXIM.webrtc.phoneLog("VI WebRTC: " + (new Date).toLocaleTimeString("en-US", t) + " " + e)
- }
- }.bind(this), this.zingayaAPI.writeTrace = function(e) {
- if ("function" == typeof this.writeTrace) this.writeTrace(e);
- else {
- var t = {
- year: "numeric",
- month: "numeric",
- day: "numeric"
- };
- this.showDebugInfo && BXIM.webrtc.phoneLog("VI WebRTC: " + (new Date).toLocaleTimeString("en-US", t) + " " + e)
- }
- }.bind(this), checkDOMReady = function() {
- "undefined" != typeof document && (clearInterval(a), this.dispatchEvent({
- name: "SDKReady",
- version: e.version
- }), this.deviceEnumAPI())
- }, a = setInterval(checkDOMReady.bind(this), 100);
- else {
- if (this.useRTCOnly) throw new Error("NO_WEBRTC_SUPPORT");
- var r = function() {
- function e() {
- if (!G) {
- try {
- var e = x.getElementsByTagName("body")[0].appendChild(v("span"));
- e.parentNode.removeChild(e)
- } catch (t) {
- return
- }
- G = !0;
- for (var n = H.length, i = 0; n > i; i++) H[i]()
- }
- }
- function n(e) {
- G ? e() : H[H.length] = e
- }
- function i(e) {
- if (typeof V.addEventListener != b) V.addEventListener("load", e, !1);
- else if (typeof x.addEventListener != b) x.addEventListener("load", e, !1);
- else if (typeof V.attachEvent != b) y(V, "onload", e);
- else if ("function" == typeof V.onload) {
- var t = V.onload;
- V.onload = function() {
- t(), e()
- }
- } else V.onload = e
- }
- function o() {
- k ? s() : a()
- }
- function s() {
- var e = x.getElementsByTagName("body")[0],
- t = v(N);
- t.setAttribute("type", L);
- var n = e.appendChild(t);
- if (n) {
- var i = 0;
- ! function() {
- if (typeof n.GetVariable != b) {
- var o = n.GetVariable("$version");
- o && (o = o.split(" ")[1].split(","), J.pv = [parseInt(o[0], 10), parseInt(o[1], 10), parseInt(o[2], 10)])
- } else if (10 > i) return i++, void setTimeout(arguments.callee, 10);
- e.removeChild(t), n = null, a()
- }()
- } else a()
- }
- function a() {
- var e = W.length;
- if (e > 0)
- for (var t = 0; e > t; t++) {
- var n = W[t].id,
- i = W[t].callbackFn,
- o = {
- success: !1,
- id: n
- };
- if (J.pv[0] > 0) {
- var s = g(n);
- if (s)
- if (!S(W[t].swfVersion) || J.wk && J.wk < 312)
- if (W[t].expressInstall && l()) {
- var a = {};
- a.data = W[t].expressInstall, a.width = s.getAttribute("width") || "0", a.height = s.getAttribute("height") || "0", s.getAttribute("class") && (a.styleclass = s.getAttribute("class")), s.getAttribute("align") && (a.align = s.getAttribute("align"));
- for (var r = {}, u = s.getElementsByTagName("param"), f = u.length, p = 0; f > p; p++) "movie" != u[p].getAttribute("name").toLowerCase() && (r[u[p].getAttribute("name")] = u[p].getAttribute("value"));
- d(a, r, n, i)
- } else h(s), i && i(o);
- else T(n, !0), i && (o.success = !0, o.ref = c(n), i(o))
- } else if (T(n, !0), i) {
- var C = c(n);
- C && typeof C.SetVariable != b && (o.success = !0, o.ref = C), i(o)
- }
- }
- }
- function c(e) {
- var t = null,
- n = g(e);
- if (n && "OBJECT" == n.nodeName)
- if (typeof n.SetVariable != b) t = n;
- else {
- var i = n.getElementsByTagName(N)[0];
- i && (t = i)
- }
- return t
- }
- function l() {
- return !B && S("6.0.65") && (J.win || J.mac) && !(J.wk && J.wk < 312)
- }
- function d(e, t, n, i) {
- B = !0, M = i || null, O = {
- success: !1,
- id: n
- };
- var o = g(n);
- if (o) {
- "OBJECT" == o.nodeName ? (E = u(o), w = null) : (E = o, w = n), e.id = F, (typeof e.width == b || !/%$/.test(e.width) && parseInt(e.width, 10) < 310) && (e.width = "310"), (typeof e.height == b || !/%$/.test(e.height) && parseInt(e.height, 10) < 137) && (e.height = "137"), x.title = x.title.slice(0, 47) + " - Flash Player Installation";
- var s = J.ie && J.win ? "ActiveX" : "PlugIn",
- a = "MMredirectURL=" + V.location.toString().replace(/&/g, "%26") + "&MMplayerType=" + s + "&MMdoctitle=" + x.title;
- if (typeof t.flashvars != b ? t.flashvars += "&" + a : t.flashvars = a, J.ie && J.win && 4 != o.readyState) {
- var r = v("div");
- n += "SWFObjectNew", r.setAttribute("id", n), o.parentNode.insertBefore(r, o), o.style.display = "none",
- function() {
- 4 == o.readyState ? o.parentNode.removeChild(o) : setTimeout(arguments.callee, 10)
- }()
- }
- f(e, t, n)
- }
- }
- function h(e) {
- if (J.ie && J.win && 4 != e.readyState) {
- var t = v("div");
- e.parentNode.insertBefore(t, e), t.parentNode.replaceChild(u(e), t), e.style.display = "none",
- function() {
- 4 == e.readyState ? e.parentNode.removeChild(e) : setTimeout(arguments.callee, 10)
- }()
- } else e.parentNode.replaceChild(u(e), e)
- }
- function u(e) {
- var t = v("div");
- if (J.win && J.ie) t.innerHTML = e.innerHTML;
- else {
- var n = e.getElementsByTagName(N)[0];
- if (n) {
- var i = n.childNodes;
- if (i)
- for (var o = i.length, s = 0; o > s; s++) 1 == i[s].nodeType && "PARAM" == i[s].nodeName || 8 == i[s].nodeType || t.appendChild(i[s].cloneNode(!0))
- }
- }
- return t
- }
- function f(e, t, n) {
- var i, o = g(n);
- if (J.wk && J.wk < 312) return i;
- if (o)
- if (typeof e.id == b && (e.id = n), J.ie && J.win) {
- var s = "";
- for (var a in e) e[a] != Object.prototype[a] && ("data" == a.toLowerCase() ? t.movie = e[a] : "styleclass" == a.toLowerCase() ? s += ' class="' + e[a] + '"' : "classid" != a.toLowerCase() && (s += " " + a + '="' + e[a] + '"'));
- var r = "";
- for (var c in t) t[c] != Object.prototype[c] && (r += '<param name="' + c + '" value="' + t[c] + '" />');
- o.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + s + ">" + r + "</object>", X[X.length] = e.id, i = g(e.id)
- } else {
- var l = v(N);
- l.setAttribute("type", L);
- for (var d in e) e[d] != Object.prototype[d] && ("styleclass" == d.toLowerCase() ? l.setAttribute("class", e[d]) : "classid" != d.toLowerCase() && l.setAttribute(d, e[d]));
- for (var h in t) t[h] != Object.prototype[h] && "movie" != h.toLowerCase() && p(l, h, t[h]);
- o.parentNode.replaceChild(l, o), i = l
- }
- return i
- }
- function p(e, t, n) {
- var i = v("param");
- i.setAttribute("name", t), i.setAttribute("value", n), e.appendChild(i)
- }
- function C(e) {
- var t = g(e);
- t && "OBJECT" == t.nodeName && (J.ie && J.win ? (t.style.display = "none", function() {
- 4 == t.readyState ? m(e) : setTimeout(arguments.callee, 10)
- }()) : t.parentNode.removeChild(t))
- }
- function m(e) {
- var t = g(e);
- if (t) {
- for (var n in t) "function" == typeof t[n] && (t[n] = null);
- t.parentNode.removeChild(t)
- }
- }
- function g(e) {
- var t = null;
- try {
- t = x.getElementById(e)
- } catch (n) {}
- return t
- }
- function v(e) {
- return x.createElement(e)
- }
- function y(e, t, n) {
- e.attachEvent(t, n), j[j.length] = [e, t, n]
- }
- function S(e) {
- var t = J.pv,
- n = e.split(".");
- return n[0] = parseInt(n[0], 10), n[1] = parseInt(n[1], 10) || 0, n[2] = parseInt(n[2], 10) || 0, t[0] > n[0] || t[0] == n[0] && t[1] > n[1] || t[0] == n[0] && t[1] == n[1] && t[2] >= n[2] ? !0 : !1
- }
- function R(e, t, n, i) {
- if (!J.ie || !J.mac) {
- var o = x.getElementsByTagName("head")[0];
- if (o) {
- var s = n && "string" == typeof n ? n : "screen";
- if (i && (A = null, P = null), !A || P != s) {
- var a = v("style");
- a.setAttribute("type", "text/css"), a.setAttribute("media", s), A = o.appendChild(a), J.ie && J.win && typeof x.styleSheets != b && x.styleSheets.length > 0 && (A = x.styleSheets[x.styleSheets.length - 1]), P = s
- }
- J.ie && J.win ? A && typeof A.addRule == N && A.addRule(e, t) : A && typeof x.createTextNode != b && A.appendChild(x.createTextNode(e + " {" + t + "}"))
- }
- }
- }
- function T(e, t) {
- if (q) {
- var n = t ? "visible" : "hidden";
- G && g(e) ? g(e).style.visibility = n : R("#" + e, "visibility:" + n)
- }
- }
- function I(e) {
- var t = /[\\\"<>\.;]/,
- n = null != t.exec(e);
- return n && typeof encodeURIComponent != b ? encodeURIComponent(e) : e
- } {
- var E, w, M, O, A, P, b = "undefined",
- N = "object",
- U = "Shockwave Flash",
- _ = "ShockwaveFlash.ShockwaveFlash",
- L = "application/x-shockwave-flash",
- F = "SWFObjectExprInst",
- D = "onreadystatechange",
- V = window,
- x = document,
- z = navigator,
- k = !1,
- H = [o],
- W = [],
- X = [],
- j = [],
- G = !1,
- B = !1,
- q = !0,
- J = function() {
- var e = typeof x.getElementById != b && typeof x.getElementsByTagName != b && typeof x.createElement != b,
- t = z.userAgent.toLowerCase(),
- n = z.platform.toLowerCase(),
- i = /win/.test(n ? n : t),
- o = /mac/.test(n ? n : t),
- s = /webkit/.test(t) ? parseFloat(t.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : !1,
- a = !1,
- r = [0, 0, 0],
- c = null;
- if (typeof z.plugins != b && typeof z.plugins[U] == N) c = z.plugins[U].description, !c || typeof z.mimeTypes != b && z.mimeTypes[L] && !z.mimeTypes[L].enabledPlugin || (k = !0, a = !1, c = c.replace(/^.*\s+(\S+\s+\S+$)/, "$1"), r[0] = parseInt(c.replace(/^(.*)\..*$/, "$1"), 10), r[1] = parseInt(c.replace(/^.*\.(.*)\s.*$/, "$1"), 10), r[2] = /[a-zA-Z]/.test(c) ? parseInt(c.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0);
- else if (typeof V.ActiveXObject != b) try {
- var l = new ActiveXObject(_);
- l && (c = l.GetVariable("$version"), c && (a = !0, c = c.split(" ")[1].split(","), r = [parseInt(c[0], 10), parseInt(c[1], 10), parseInt(c[2], 10)]))
- } catch (d) {}
- return {
- w3: e,
- pv: r,
- wk: s,
- ie: a,
- win: i,
- mac: o
- }
- }();
- ! function() {
- J.w3 && ((typeof x.readyState != b && "complete" == x.readyState || typeof x.readyState == b && (x.getElementsByTagName("body")[0] || x.body)) && e(), G || (typeof x.addEventListener != b && x.addEventListener("DOMContentLoaded", e, !1), J.ie && J.win && (x.attachEvent(D, function() {
- "complete" == x.readyState && (x.detachEvent(D, arguments.callee), e())
- }), V == top && ! function() {
- if (!G) {
- try {
- x.documentElement.doScroll("left")
- } catch (t) {
- return void setTimeout(arguments.callee, 0)
- }
- e()
- }
- }()), J.wk && ! function() {
- return G ? void 0 : /loaded|complete/.test(x.readyState) ? void e() : void setTimeout(arguments.callee, 0)
- }(), i(e)))
- }(),
- function() {
- J.ie && J.win && window.attachEvent("onunload", function() {
- for (var e = j.length, t = 0; e > t; t++) j[t][0].detachEvent(j[t][1], j[t][2]);
- for (var n = X.length, i = 0; n > i; i++) C(X[i]);
- for (var o in J) J[o] = null;
- J = null;
- for (var s in r) r[s] = null;
- r = null
- })
- }()
- }
- return {
- registerObject: function(e, t, n, i) {
- if (J.w3 && e && t) {
- var o = {};
- o.id = e, o.swfVersion = t, o.expressInstall = n, o.callbackFn = i, W[W.length] = o, T(e, !1)
- } else i && i({
- success: !1,
- id: e
- })
- },
- getObjectById: function(e) {
- return J.w3 ? c(e) : void 0
- },
- embedSWF: function(e, t, i, o, s, a, r, c, h, u) {
- var p = {
- success: !1,
- id: t
- };
- J.w3 && !(J.wk && J.wk < 312) && e && t && i && o && s ? (T(t, !1), n(function() {
- i += "", o += "";
- var n = {};
- if (h && typeof h === N)
- for (var C in h) n[C] = h[C];
- n.data = e, n.width = i, n.height = o;
- var m = {};
- if (c && typeof c === N)
- for (var g in c) m[g] = c[g];
- if (r && typeof r === N)
- for (var v in r) typeof m.flashvars != b ? m.flashvars += "&" + v + "=" + r[v] : m.flashvars = v + "=" + r[v];
- if (S(s)) {
- var y = f(n, m, t);
- n.id == t && T(t, !0), p.success = !0, p.ref = y
- } else {
- if (a && l()) return n.data = a, void d(n, m, t, u);
- T(t, !0)
- }
- u && u(p)
- })) : u && u(p)
- },
- switchOffAutoHideShow: function() {
- q = !1
- },
- ua: J,
- getFlashPlayerVersion: function() {
- return {
- major: J.pv[0],
- minor: J.pv[1],
- release: J.pv[2]
- }
- },
- hasFlashPlayerVersion: S,
- createSWF: function(e, n, i) {
- return J.w3 ? f(e, n, i) : t
- },
- showExpressInstall: function(e, t, n, i) {
- J.w3 && l() && d(e, t, n, i)
- },
- removeSWF: function(e) {
- J.w3 && C(e)
- },
- createCSS: function(e, t, n, i) {
- J.w3 && R(e, t, n, i)
- },
- addDomLoadEvent: n,
- addLoadEvent: i,
- getQueryParamValue: function(e) {
- var t = x.location.search || x.location.hash;
- if (t) {
- if (/\?/.test(t) && (t = t.split("?")[1]), null == e) return I(t);
- for (var n = t.split("&"), i = 0; i < n.length; i++)
- if (n[i].substring(0, n[i].indexOf("=")) == e) return I(n[i].substring(n[i].indexOf("=") + 1))
- }
- return ""
- },
- expressInstallCallback: function() {
- if (B) {
- var e = g(F);
- e && E && (e.parentNode.replaceChild(E, e), w && (T(w, !0), J.ie && J.win && (E.style.display = "block")), M && M(O)), B = !1
- }
- }
- }
- }();
- if (createContainer = function() {
- if ("undefined" != typeof document) {
- var e;
- if (clearInterval(a), null !== this.swfContainer) {
- if (e = document.getElementById(this.swfContainer), null === e) throw new Error("NO_SWF_CONTAINER");
- e.offsetWidth < 215 && (e.style.minWidth = e.style.width = "215px"), e.offsetHeight < 138 && (e.style.minHeight = e.style.height = "138px")
- } else e = document.createElement("div"), this.swfContainer = e.id = "voximplantcontainer", e.style.minWidth = e.style.width = "215px", e.style.minHeight = e.style.height = "138px", document.body.firstChild ? document.body.insertBefore(e, document.body.firstChild) : document.body.appendChild(e); - 1 != navigator.userAgent.indexOf("Safari") && (e.style.minWidth = e.style.width = "310px");
- var t = document.createElement("div");
- t.id = "voximplantcontainerSWF", e.appendChild(t);
- var n = {
- id: "voximplantSWF",
- name: "voximplantSWF"
- },
- i = !1,
- s = {
- allowScriptAccess: "always",
- wmode: "window",
- allowFullScreen: "true"
- };
- window.voxImplantFlashAPIReady = o.bind(this);
- var c = ("https:" == document.location.protocol ? "https://" : "http://") + "cdn.voximplant.com/VoxImplant-3.0.swf?ver=080515";
- "undefined" != typeof this.swfURL && (c = this.swfURL), r.embedSWF(c, "voximplantcontainerSWF", "100%", "100%", "11.3", "http://cdn.voximplant.com/expressInstall.swf", i, s, n)
- }
- }, !r.hasFlashPlayerVersion("11.3")) throw new Error("OLD_FLASH_VERSION");
- a = setInterval(createContainer.bind(this), 100)
- }
- window.VILog = function(e) {
- if ("function" == typeof this.writeLog) this.writeLog(e);
- else {
- var t = {
- year: "numeric",
- month: "numeric",
- day: "numeric"
- };
- this.showDebugInfo && "undefined" != typeof console && BXIM.webrtc.phoneLog("VI FLASH: " + (new Date).toLocaleTimeString("en-US", t) + " " + e)
- }
- }.bind(this), window.VIConnectionEstablished = function() {
- this.connectionState(!0), this.dispatchEvent({
- name: "ConnectionEstablished"
- })
- }.bind(this), window.VIConnectionFailed = function() {
- this.serversList.length > 1 && "undefined" == typeof this.serverIp ? (this.serversList.splice(0, 1), this.connectTo(this.serversList[0], !0)) : this.dispatchEvent({
- name: "ConnectionFailed"
- })
- }.bind(this), window.VIConnectionClosed = function() {
- this.connectionState(!1), this.__cleanup(), this.dispatchEvent({
- name: "ConnectionClosed"
- }), this.progressTone && this.stopProgressTone()
- }.bind(this), window.VIAuthFailed = function(e, t) {
- this.dispatchEvent({
- name: "AuthResult",
- result: !1,
- code: e,
- key: t
- })
- }.bind(this), window.VIAuthSuccessful = function(e, t) {
- "string" == typeof t && (t = JSON.parse(t)), this.dispatchEvent({
- name: "AuthResult",
- result: !0,
- displayName: e,
- options: t
- })
- }.bind(this), window.VICallConnected = function(e, t) {
- this.getCall(e).dispatchEvent({
- name: "Connected",
- call: this.getCall(e),
- headers: null !== t ? JSON.parse(t) : {}
- }), this.progressTone && this.stopProgressTone()
- }.bind(this), window.VICallDisconnected = function(e, t) {
- this.getCall(e).dispatchEvent({
- name: "Disconnected",
- call: this.getCall(e),
- headers: null !== t ? JSON.parse(t) : {}
- }), this.removeCall(e), this.progressTone && this.stopProgressTone()
- }.bind(this), window.VICallFailed = function(e, t, n, i) {
- this.getCall(e).dispatchEvent({
- name: "Failed",
- call: this.getCall(e),
- code: t,
- reason: n,
- headers: null !== i ? JSON.parse(i) : {}
- }), this.removeCall(e), this.progressTone && this.stopProgressTone()
- }.bind(this), window.VIMicAccessResult = function(e) {
- this.dispatchEvent({
- name: "MicAccessResult",
- result: e
- })
- }.bind(this), window.VIProgressToneStart = function(e) {
- this.getCall(e).dispatchEvent({
- name: "ProgressToneStart",
- call: this.getCall(e)
- }), this.progressTone && this.playProgressTone()
- }.bind(this), window.VIProgressToneStop = function(e) {
- this.getCall(e).dispatchEvent({
- name: "ProgressToneStop",
- call: this.getCall(e)
- }), this.progressTone && this.stopProgressTone()
- }.bind(this), window.VIIncomingCall = function(e, t, i, o) {
- var s = new n(e, t, i, null !== o ? JSON.parse(o) : {}, !1);
- this.calls.length > 0 && this.zingayaAPI.setCallActive(e, !1), this.calls.push(s), this.dispatchEvent({
- name: "IncomingCall",
- call: s,
- headers: null !== o ? JSON.parse(o) : {}
- })
- }.bind(this), window.VISIPInfoReceived = function(e, t, n, i, o) {
- "application" == t && "zingaya-im" == n ? this.getCall(e).dispatchEvent({
- name: "MessageReceived",
- call: this.getCall(e),
- text: i
- }) : (null !== o && (o = JSON.parse(o)), this.getCall(e).dispatchEvent({
- name: "InfoReceived",
- call: this.getCall(e),
- mimeType: t + "/" + n,
- body: i,
- headers: o
- }))
- }.bind(this), window.VIToneScriptPlaybackStop = function() {
- this.dispatchEvent({
- name: "PlaybackFinished"
- })
- }.bind(this), window.VITransferComplete = function(e) {
- this.getCall(e).dispatchEvent({
- name: "TransferComplete",
- call: this.getCall(e)
- })
- }.bind(this), window.VITransferFailed = function(e) {
- this.getCall(e).dispatchEvent({
- name: "TransferFailed",
- call: this.getCall(e)
- })
- }.bind(this), window.VIPacketLossInfo = function(e) {
- this.dispatchEvent({
- name: "NetStatsReceived",
- stats: {
- packetLoss: e
- }
- })
- }.bind(this), window.VIHandleRoster = function(e, t) {
- this.dispatchEvent({
- name: "RosterReceived",
- id: e,
- roster: JSON.parse(t)
- })
- }.bind(this), window.VIHandleRosterPresence = function(e, t, n, i) {
- this.dispatchEvent({
- name: "RosterPresenceUpdate",
- id: e,
- resource: t,
- presence: n,
- message: i
- })
- }.bind(this), window.VIHandleMessage = function(e, t, n, i) {
- if (this.imXSSprotection) {
- var o = document.createElement("div");
- o.appendChild(document.createTextNode(n)), n = o.innerHTML
- }
- this.dispatchEvent({
- name: "MessageReceived",
- id: e,
- resource: t,
- content: n,
- message_id: i
- })
- }.bind(this), window.VIHandlePresence = function(e, t, n, i) {
- this.dispatchEvent({
- name: "PresenceUpdate",
- id: e,
- resource: t,
- presence: n,
- message: i
- })
- }.bind(this), window.VIHandleChateState = function(e, t, n) {
- this.dispatchEvent({
- name: "ChatStateUpdate",
- id: e,
- resource: t,
- state: n
- })
- }.bind(this), window.VIHandleMessageEvent = function(e, t, n, i) {
- this.dispatchEvent({
- name: "MessageStatus",
- id: e,
- resource: t,
- type: n,
- message_id: i
- })
- }.bind(this), window.VIHandleRosterItem = function(e, t, n, i, o) {
- this.dispatchEvent({
- name: "RosterItemChange",
- id: e,
- resource: t,
- type: n,
- displayName: o
- })
- }.bind(this), window.VIHandleSubscription = function(e, t, n, i) {
- this.dispatchEvent({
- name: "SubscriptionRequest",
- id: e,
- resource: t,
- type: n,
- message: i
- })
- }.bind(this), window.VIHandleRemoteFunctionError = function(e, t, n, i) {
- this.dispatchEvent({
- name: "IMError",
- errorType: "RemoteFunctionError",
- errorData: {
- method: e,
- params: JSON.parse(t),
- code: n,
- description: i
- }
- })
- }.bind(this), window.VIHandleIMError = function(e, t, n) {
- this.dispatchEvent({
- name: "IMError",
- errorType: "Error",
- errorData: {
- type: e,
- code: t,
- description: n
- }
- })
- }.bind(this), window.VIHandleIMRosterError = function(e) {
- this.dispatchEvent({
- name: "IMError",
- errorType: "RosterError",
- errorData: {
- code: e
- }
- })
- }.bind(this)
- }, this.connectionState = function(e) {
- return "undefined" == typeof e ? i : void(i = e)
- }, this.getCall = function(e) {
- for (var t = 0; t < this.calls.length; t++)
- if (this.calls[t].call() == e) return this.calls[t];
- return null
- }, this.removeCall = function(e) {
- for (var t = [], n = 0; n < this.calls.length; n++) this.calls[n].call() != e ? t.push(this.calls[n]) : delete this.calls[n];
- this.calls = t
- }, this.playProgressTone = function() {
- null !== this.progressToneScript[this.progressToneCountry] && (this.playingNow || this.playToneScript(this.progressToneScript[this.progressToneCountry]), this.playingNow = !0)
- }, this.stopProgressTone = function() {
- this.playingNow && (this.stopPlayback(), this.playingNow = !1)
- }, this.__call = function(t, i, o, s) {
- if ("undefined" != typeof o && ("undefined" == typeof s && (s = {}), s["VI-CallData"] = o), !this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- var a, r;
- return this.RTCsupported && !this.useFlashOnly ? (a = this.zingayaAPI.callTo(t, i, s), r = new n(a, t, "", s, !0, this.zingayaAPI), this.calls.length > 0 && this.zingayaAPI.setCallActive(a, !1)) : this.useRTCOnly || (s = JSON.stringify(s), a = e.Utils.swfMovie("voximplantSWF").call(t, i, null, s), r = new n(a, t, "", s, !1), this.calls.length > 0 && e.Utils.swfMovie("voximplantSWF").setCallActive(a, !1)), this.calls.push(r), r
- }, this.__volume = function(e) {
- return "undefined" == typeof e ? o : void(o = e)
- }, this.__cleanup = function() {
- if (this.calls.length > 0) {
- var e, t = [];
- for (e in this.calls) t.push(this.calls[e].id()), this.connectionState() && this.calls[e].hangup();
- for (e in t) this.removeCall(t[e])
- }
- }
- }, e.Client.prototype = {
- call: function(e, t, n, i) {
- return this.__call(e, t, n, i)
- },
- config: function() {
- return this.config
- },
- connect: function() {
- "undefined" != typeof this.serverIp ? (host = this.serverIp, this.connectTo(host)) : (balancerResult = function(e) {
- var t = String(e).indexOf(";"); - 1 == t ? host = e : (this.serversList = e.split(";"), host = this.serversList[0]), this.connectTo(host)
- }, e.Utils.getServers(balancerResult.bind(this), !1, this))
- },
- connectTo: function(t, n) {
- if (this.connectionState()) throw new Error("ALREADY_CONNECTED_TO_VOXIMPLANT");
- this.host = t, this.RTCsupported && !this.useFlashOnly ? this.micRequired && n !== !0 ? (this.videoSupport && this.zingayaAPI.setConstraints(this.videoConstraints, null, null, !1), this.zingayaAPI.requestMedia(this.videoSupport, this.zingayaAPI.onMediaAccessGranted, this.zingayaAPI.onMediaAccessRejected)) : this.zingayaAPI.connectTo(t, "platform") : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").connect(t, n === !0 ? !1 : this.micRequired, this.micRequired && this.showFlashSettings)
- },
- disconnect: function() {
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- this.__cleanup(), this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.destroy() : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").disconnect()
- },
- init: function(e) {
- this.__init(e)
- },
- setOperatorACDStatus: function(t) {
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.setOperatorACDStatus(t) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").setOperatorACDStatus(t)
- },
- login: function(t, n, i) {
- if (i = "undefined" != typeof i ? i : {}, i = e.Utils.extend({}, i), !this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.login(t, n, i) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").login(t, n, JSON.stringify(i))
- },
- loginWithCode: function(t, n, i) {
- if (i = "undefined" != typeof i ? i : {}, i = e.Utils.extend({
- serverPresenceControl: !1
- }, i), !this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.loginStage2(t, n, i) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").loginStage2(t, n, JSON.stringify(i))
- },
- requestOneTimeLoginKey: function(t) {
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.loginGenerateOneTimeKey(t) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").requestOneTimeLoginKey(t)
- },
- loginWithOneTimeKey: function(t, n, i) {
- if (i = "undefined" != typeof i ? i : {}, i = e.Utils.extend({
- serverPresenceControl: !1
- }, i), !this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.loginUsingOneTimeKey(t, n, i) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").loginUsingOneTimeKey(t, n, JSON.stringify(i))
- },
- connected: function() {
- return this.connectionState()
- },
- showLocalVideo: function(t) {
- if ("undefined" == typeof t && (t = !0), this.RTCsupported && !this.useFlashOnly)
- if (t)
- if (null === document.getElementById("voximplantlocalvideo")) {
- var n = document.createElement("video");
- n.id = "voximplantlocalvideo", n.autoplay = "autoplay", n.muted = "true", document.body.firstChild ? document.body.insertBefore(n, document.body.firstChild) : document.body.appendChild(n), this.zingayaAPI.setLocalVideoSink(n)
- } else document.getElementById("voximplantlocalvideo").style.display = "block";
- else document.getElementById("voximplantlocalvideo").style.display = "none";
- else this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").showLocalVideo(t)
- },
- setLocalVideoPosition: function(t, n) {
- if (this.RTCsupported && !this.useFlashOnly) throw new Error("Please use CSS to position '#voximplantlocalvideo' element");
- this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").setSelfViewPosition(t, n)
- },
- setLocalVideoSize: function(t, n) {
- if (this.RTCsupported && !this.useFlashOnly) throw new Error("Please use CSS to set size of '#voximplantlocalvideo' element");
- this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").setSelfViewSize(t, n)
- },
- setVideoSettings: function(t, n, i, o) {
- if (this.RTCsupported && !this.useFlashOnly) this.zingayaAPI.setConstraints(t, function() {
- null !== document.getElementById("voximplantlocalvideo") && this.zingayaAPI.setLocalVideoSink(document.getElementById("voximplantlocalvideo")), this.videoConstraints = t, "function" == typeof n && n()
- }.bind(this), i, !0);
- else if (!this.useRTCOnly) {
- "[object Object]" == Object.prototype.toString.call(t) && (t = JSON.stringify(t));
- try {
- e.Utils.swfMovie("voximplantSWF").setVideoSettings(t)
- } catch (s) {
- "function" == typeof i && i()
- }
- "function" == typeof n && n()
- }
- },
- setVideoBandwidth: function(e) {
- this.RTCsupported && !this.useFlashOnly && (this.zingayaAPI.setVideoBandwidth(e), this.zingayaAPI.setDesiredVideoBandwidth(e))
- },
- playToneScript: function(t, n) {
- this.RTCsupported && !this.useFlashOnly ? e.Utils.playToneScript(t, n) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").playToneScript(t, n)
- },
- stopPlayback: function() {
- this.RTCsupported && !this.useFlashOnly ? e.Utils.stopPlayback() && this.dispatchEvent({
- name: "PlaybackFinished"
- }) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").stopPlayback()
- },
- volume: function(t) {
- return "undefined" == typeof t ? this.__volume() : (t > 100 && (t = 100), 0 > t && (t = 0), this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.setPlaybackVolume(t / 100) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").changeIncomingAudioVolume(t), this.__volume(t), void 0)
- },
- audioSources: function() {
- if (this.RTCsupported && !this.useFlashOnly && !this.deviceEnumAPI) throw new Error("NOT_SUPPORTED: enumerateDevices");
- return this.audioSourcesList
- },
- videoSources: function() {
- if (this.RTCsupported && !this.useFlashOnly && !this.deviceEnumAPI) throw new Error("NOT_SUPPORTED: enumerateDevices");
- return this.videoSourcesList
- },
- audioOutputs: function() {
- if (this.RTCsupported && !this.useFlashOnly && !this.deviceEnumAPI) throw new Error("NOT_SUPPORTED: enumerateDevices");
- return this.audioOutputsList
- },
- useAudioSource: function(t, n, i) {
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.useAudioSource(t, n, i) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").setAudioSource(t)
- },
- useVideoSource: function(t, n, i) {
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.useVideoSource(t, function() {
- null !== document.getElementById("voximplantlocalvideo") && this.zingayaAPI.setLocalVideoSink(document.getElementById("voximplantlocalvideo")), "function" == typeof n && n()
- }.bind(this), i) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").setVideoSource(t)
- },
- attachRecordingDevice: function(e, t) {
- !this.RTCsupported || this.useFlashOnly || this.micRequired || this.zingayaAPI.requestMedia(this.videoSupport, e, t)
- },
- detachRecordingDevice: function() {
- !this.RTCsupported || this.useFlashOnly || this.micRequired || this.zingayaAPI.stopLocalStream()
- },
- showFlashSettingsPanel: function(t) {
- "undefined" == typeof t && (t = "default"), this.RTCsupported && !this.useFlashOnly || this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").showFlashSettings(t)
- },
- setCallActive: function(t, n) {
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.setCallActive(t.call(), n) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").setCallActive(t.call(), n)
- },
- sendVideo: function(t) {
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- "undefined" == typeof t && (t = !0), this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.sendVideo(t) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").sendVideo(t)
- },
- isRTCsupported: function() {
- return this.RTCsupported
- },
- transferCall: function(t, n) {
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.transferCall(t.call(), n.call()) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").transferCall(t.call(), n.call())
- },
- setSwfColor: function(t) {
- this.RTCsupported && !this.useFlashOnly || this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").setStageColor(t)
- },
- setCodecPayload: function(t) {
- this.RTCsupported && !this.useFlashOnly || this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").setCodecPayload(t)
- },
- startScreenSharing: function() {
- this.RTCsupported && !this.useFlashOnly && this.zingayaAPI.shareScreen()
- }
- }, e.Client.prototype.addEventListener = function(e, t) {
- "undefined" == typeof this.eventListeners[e] && (this.eventListeners[e] = []), this.eventListeners[e].push(t)
- }, e.Client.prototype.removeEventListener = function(e, t) {
- if ("undefined" != typeof this.eventListeners[e])
- for (var n = 0; n < this.eventListeners[e].length; n++)
- if (this.eventListeners[e][n] == t) {
- this.eventListeners[e].splice(n, 1);
- break
- }
- }, e.Client.prototype.dispatchEvent = e.Call.prototype.dispatchEvent = function(e) {
- var t = e.name;
- if ("undefined" != typeof this.eventListeners[t])
- for (var n = 0; n < this.eventListeners[t].length; n++) "function" == typeof this.eventListeners[t][n] && this.eventListeners[t][n](e)
- }
- }(i), function(e, t) {
- e.Client.prototype.addRosterItem = function(t, n, i) {
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- "undefined" == typeof i && (i = ""), this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.addRoster(t, n, i) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").addRosterItem(t, n, i)
- }, e.Client.prototype.removeRosterItem = function(t) {
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.removeRoster(t) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").removeRosterItem(t)
- }, e.Client.prototype.renameRosterItem = function(t, n) {
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.renameRosterItem(t, n) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").renameRosterItem(t, n)
- }, e.Client.prototype.addRosterItemGroup = function(t, n) {
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.addRosterItemGroup(t, n) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").addRosterItemGroup(t, n)
- }, e.Client.prototype.removeRosterItemGroup = function(t, n) {
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.delRosterItemGroup(t, n) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").delRosterItemGroup(t, n)
- }, e.Client.prototype.moveRosterItemGroup = function(t, n, i) {
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.moveRosterItemGroup(t, n, i) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").moveRosterItemGroup(t, n, i)
- }, e.Client.prototype.sendInstantMessage = function(t, n) {
- var i = e.Utils.generateUUID();
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- return this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.sendTextMessage(t, n, i) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").sendInstantMessage(t, n, i), i
- }, e.Client.prototype.editInstantMessage = function(e, t, n) {
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.editTextMessage(e, t, n) : !this.useRTCOnly
- }, e.Client.prototype.removeInstantMessage = function(e, t) {
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.removeTextMessage(e, t) : !this.useRTCOnly
- }, e.Client.prototype.setChatState = function(t, n) {
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.sendChatState(t, n) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").sendChatState(t, n)
- }, e.Client.prototype.setMessageStatus = function(t, n, i) {
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- if ("string" == typeof i) i = [i];
- else if (!Array.isArray(i)) throw new Error("message_id should be string or array");
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.raiseMessageEvent(t, n, JSON.stringify(i)) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").raiseMessageEvent(t, n, JSON.stringify(i))
- }, e.Client.prototype.setPresenceStatus = function(t, n) {
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.sendStatus(t, n) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").sendStatus(t, n)
- }, e.Client.prototype.createChatRoom = function(t, n) {
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- var i = e.Utils.generateUUID();
- return this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.joinMUC(i, t, n) : !this.useRTCOnly, i
- }, e.Client.prototype.joinChatRoom = function(e, t) {
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.joinMUC(e, t) : !this.useRTCOnly
- }, e.Client.prototype.acceptChatRoomInvite = e.Client.prototype.joinChatRoom, e.Client.prototype.leaveChatRoom = function(e, t) {
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.leaveMUC(e, t) : !this.useRTCOnly
- }, e.Client.prototype.sendChatRoomMessage = function(t, n) {
- var i = e.Utils.generateUUID();
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- return this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.sendMUCMessage(t, n, i) : !this.useRTCOnly, i
- }, e.Client.prototype.editChatRoomMessage = function(e, t, n) {
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.editMUCMessage(e, t, n) : !this.useRTCOnly
- }, e.Client.prototype.removeChatRoomMessage = function(e, t) {
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.removeMUCMessage(e, t) : !this.useRTCOnly
- }, e.Client.prototype.inviteToChatRoom = function(e, t, n, i) {
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.inviteMUC(e, t, n, i) : !this.useRTCOnly
- }, e.Client.prototype.declineChatRoomInvite = function(e, t, n) {
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.declineMUCinvitation(e, t, n) : !this.useRTCOnly
- }, e.Client.prototype.setChatRoomSubject = function(e, t) {
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.setSubject(e, t) : !this.useRTCOnly
- }, e.Client.prototype.removeChatRoomUser = function(e, t, n) {
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.kickMUCUser(e, t, n) : !this.useRTCOnly
- }, e.Client.prototype.banChatRoomUser = function(e, t, n) {
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.banMUCUser(e, t, n) : !this.useRTCOnly
- }, e.Client.prototype.unbanChatRoomUser = function(e, t, n) {
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.unbanMUCUser(e, t, n) : !this.useRTCOnly
- }, e.Client.prototype.getInstantMessagingHistory = function(e, t, n, i) {
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.requestHistory(e, t, n, i) : !this.useRTCOnly
- }, e.Client.prototype.getChatRoomHistory = function(e, t, n, i) {
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.requestMUCHistory(e, t, n, i) : !this.useRTCOnly
- }, e.Client.prototype.setChatRoomState = function(e, t) {
- if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
- this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.sendMUCChatState(e, t) : !this.useRTCOnly
- }
- }(i), Function.prototype.bind || (Function.prototype.bind = function(e) {
- if ("function" != typeof this) throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
- var t = Array.prototype.slice.call(arguments, 1),
- n = this,
- i = function() {},
- o = function() {
- return n.apply(this instanceof i && e ? this : e, t.concat(Array.prototype.slice.call(arguments)))
- };
- return i.prototype = this.prototype, o.prototype = new i, o
- }), !window.JSON) throw new Error("Unsupported browser");
- ! function(e, n) {
- e.Utils = {
- source: null,
- extend: function(e) {
- var t = {},
- n = function(e) {
- for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && (t[n] = e[n])
- };
- n(arguments[0]);
- for (var i = 1; i < arguments.length; i++) {
- var o = arguments[i];
- n(o)
- }
- return t
- },
- swfMovie: function(e) {
- return -1 != navigator.appName.indexOf("Microsoft") ? window[e] : document[e]
- },
- stringifyExtraHeaders: function(e) {
- return e = "[object Object]" == Object.prototype.toString.call(e) ? JSON.stringify(e) : null
- },
- cadScript: function(e) {
- var t = e.split(";");
- return t.map(function(e) {
- if (0 !== e.length) {
- var t = e.match(/\([0-9\/\.,\*\+]*\)$/),
- n = e.substring(0, t.index),
- i = t.pop();
- if (t.length) throw new Error("cadence script should be of the form `%f(%f/%f[,%f/%f])`");
- if (n = "*" === n ? 1 / 0 : parseFloat(n), isNaN(n)) throw new Error("cadence length should be of the form `%f`");
- return i = i.slice(1, i.length - 1).split(",").map(function(e) {
- try {
- var t = e.split("/");
- if (t.length > 3) throw new Error;
- return t = t.map(function(e, t) {
- if (2 === t) {
- var n = e.split("+").map(function(e) {
- var t = parseInt(e, 10);
- if (isNaN(t)) throw new Error;
- return t - 1
- });
- return n
- }
- var i;
- if ("*" == e && (i = 1 / 0), i = i ? i : parseFloat(e, 10), isNaN(i)) throw new Error;
- return i
- }), {
- on: t[0],
- off: t[1],
- frequencies: t[2]
- }
- } catch (n) {
- throw new Error("cadence segments should be of the form `%f/%f[%d[+%d]]`")
- }
- }), {
- duration: n,
- sections: i
- }
- }
- })
- },
- freqScript: function(e) {
- var t = e.split(",");
- return t.map(function(e) {
- try {
- var t = e.split("@"),
- n = parseInt(t.shift()),
- i = parseFloat(t.shift());
- if (t.length) throw Error();
- return {
- frequency: n,
- decibels: i
- }
- } catch (o) {
- throw new Error("freqScript pairs are expected to be of the form `%d@%f[,%d@%f]`")
- }
- })
- },
- toneScript: function(t) {
- var n = t.split(";"),
- i = e.Utils.freqScript(n.shift()),
- o = e.Utils.cadScript(n.join(";"));
- return {
- frequencies: i,
- cadences: o
- }
- },
- playToneScript: function(n, i) {
- if ("undefined" != typeof window.AudioContext || "undefined" != typeof window.webkitAudioContext) {
- window.AudioContext = window.AudioContext || window.webkitAudioContext;
- var o = new AudioContext,
- s = e.Utils.toneScript(n),
- a = [],
- r = 0;
- processCadence = function(e) {
- r += e.duration != 1 / 0 ? e.duration : 20;
- for (var t = 0; t < e.sections.length; t++) processSection(e.sections[t], e.duration)
- }, processSection = function(e, n) {
- if (t = n != 1 / 0 ? n : n = 20, 0 !== e.off && e.off != 1 / 0)
- for (; t > 0;) addSound(e.frequencies, e.on), t -= e.on, addSilence(e.off), t -= e.off, t = parseInt(10 * t) / 10;
- else addSound(e.frequencies, n)
- }, addSilence = function(e) {
- for (var t = 0; t < o.sampleRate * e; t++) a.push(0)
- }, addSound = function(e, t) {
- for (var n = 0; n < o.sampleRate * t; n++) {
- for (var i = 0, r = 0; r < e.length; r++) i += Math.pow(10, s.frequencies[e[r]].decibels / 20) * Math.sin((a.length + n) * (3.14159265359 / o.sampleRate) * s.frequencies[e[r]].frequency), 10 > n && (i *= n / 10), n > o.sampleRate * t - 10 && (i *= (o.sampleRate * t - n) / 10);
- a.push(i)
- }
- }, this.source = o.createBufferSource();
- for (var c = 0; c < s.cadences.length; c++) s.cadences[c].duration == 1 / 0 && (this.source.loop = !0), processCadence(s.cadences[c]);
- this.source.connect(o.destination), sndBuffer = o.createBuffer(1, r * o.sampleRate, o.sampleRate), bufferData = sndBuffer.getChannelData(0);
- for (var l = 0; l < r * o.sampleRate; l++) bufferData[l] = a[l];
- a = null, this.source.buffer = sndBuffer, i === !0 && (this.source.loop = !0), this.source.start(0)
- }
- },
- stopPlayback: function() {
- return null !== this.source ? (this.source.stop(0), this.source = null, !0) : !1
- },
- sendRequest: function(e, t, n, i) {
- var o = !1,
- s = function() {
- for (var e = [function() {
- return new XDomainRequest
- }, function() {
- return new XMLHttpRequest
- }, function() {
- return new ActiveXObject("Msxml2.XMLHTTP")
- }, function() {
- return new ActiveXObject("Msxml3.XMLHTTP")
- }, function() {
- return new ActiveXObject("Microsoft.XMLHTTP")
- }], t = !1, n = 0; n < e.length; n++) {
- try {
- t = e[n](), 0 === n && (o = !0)
- } catch (i) {
- continue
- }
- break
- }
- return t
- },
- a = s();
- if (a) {
- var r = i ? "POST" : "GET";
- if (o) a.onerror = function() {
- n(a)
- }, a.ontimeout = function() {
- n(a)
- }, a.onload = function() {
- t(a)
- }, a.open(r, e), a.timeout = 5e3, a.send();
- else {
- if (a.open(r, e, !0), i && a.setRequestHeader("Content-type", "application/x-www-form-urlencoded"), a.onreadystatechange = function() {
- return 4 == a.readyState ? 200 != a.status && 304 != a.status ? void n(a) : void t(a) : void 0
- }, 4 == a.readyState) return;
- a.send(i)
- }
- }
- },
- getServers: function(t, n, i) {
- function o(o) {
- null !== o ? t(o) : n !== !0 ? e.Utils.getServers(t, !0, i) : i.dispatchEvent({
- name: "ConnectionFailed",
- message: "VoxImplant Cloud is unavailable"
- })
- }
- var s = "https:" == document.location.protocol ? "https://" : "http://";
- balancer_url = n === !0 ? s + "balancer2.voximplant.com/getNearestHost" : s + "balancer.voximplant.com/getNearestHost", e.Utils.sendRequest(balancer_url, function(e) {
- o(e.responseText)
- }, function(e) {
- o(null)
- })
- },
- generateUUID: function() {
- var t = e.Utils._gri,
- n = e.Utils._ha;
- return n(t(32), 8) + "-" + n(t(16), 4) + "-" + n(16384 | t(12), 4) + "-" + n(32768 | t(14), 4) + "-" + n(t(48), 12)
- },
- _gri: function(e) {
- return 0 > e ? 0 / 0 : 30 >= e ? 0 | Math.random() * (1 << e) : 53 >= e ? (0 | Math.random() * (1 << 30)) + (0 | Math.random() * (1 << e - 30)) * (1 << 30) : 0 / 0
- },
- _ha: function(e, t) {
- for (var n = e.toString(16), i = t - n.length, o = "0"; i > 0; i >>>= 1, o += o) 1 & i && (n = o + n);
- return n
- },
- filterXSS: function(e) {
- var t = document.createElement("div");
- return t.appendChild(document.createTextNode(e)), e = t.innerHTML
- }
- }, e.getInstance = function() {
- return e._clientInstance
- }, e.version = e.Client.prototype.version = "3.5.17994", e._clientInstance || (e._clientInstance = new e.Client, delete e.Client)
- }(i), "undefined" != typeof exports ? (exports["default"] = exports.VoxImplant = i, "undefined" != typeof module && module.exports && (exports = module.exports = exports["default"])) : n.VoxImplant = i
- }).call(this);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement