module-develop-kit 0.5.10 → 0.5.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs-virtual-dir/Config.js +4 -0
- package/dist/commonjs-virtual-dir/Constants.js +5 -0
- package/dist/commonjs-virtual-dir/DTMF.js +4 -0
- package/dist/commonjs-virtual-dir/JsSIP.js +5 -0
- package/dist/commonjs-virtual-dir/Parser2.js +4 -0
- package/dist/commonjs-virtual-dir/Socket.js +4 -0
- package/dist/commonjs-virtual-dir/Utils.js +4 -0
- package/dist/commonjs-virtual-dir/___vite-browser-external.js +6 -0
- package/dist/commonjs-virtual-dir/__vite-browser-external.js +4 -0
- package/dist/commonjs-virtual-dir/_commonjs-dynamic-modules.js +6 -0
- package/dist/commonjs-virtual-dir/_commonjsHelpers.js +33 -0
- package/dist/commonjs-virtual-dir/_virtual_mobile-compatibility-detection.js +4 -0
- package/dist/commonjs-virtual-dir/_virtual_pc-compatibility-detection.js +4 -0
- package/dist/commonjs-virtual-dir/aes.js +4 -0
- package/dist/commonjs-virtual-dir/blowfish.js +4 -0
- package/dist/commonjs-virtual-dir/browser.js +4 -0
- package/dist/commonjs-virtual-dir/cipher-core.js +4 -0
- package/dist/commonjs-virtual-dir/core.js +4 -0
- package/dist/commonjs-virtual-dir/enc-base64.js +4 -0
- package/dist/commonjs-virtual-dir/enc-base64url.js +4 -0
- package/dist/commonjs-virtual-dir/enc-utf16.js +4 -0
- package/dist/commonjs-virtual-dir/events.js +4 -0
- package/dist/commonjs-virtual-dir/evpkdf.js +4 -0
- package/dist/commonjs-virtual-dir/format-hex.js +4 -0
- package/dist/commonjs-virtual-dir/grammar.js +4 -0
- package/dist/commonjs-virtual-dir/hmac.js +4 -0
- package/dist/commonjs-virtual-dir/index.js +5 -0
- package/dist/commonjs-virtual-dir/index2.js +5 -0
- package/dist/commonjs-virtual-dir/index3.js +7 -0
- package/dist/commonjs-virtual-dir/index4.js +7 -0
- package/dist/commonjs-virtual-dir/index5.js +4 -0
- package/dist/commonjs-virtual-dir/index6.js +4 -0
- package/dist/commonjs-virtual-dir/index7.js +4 -0
- package/dist/commonjs-virtual-dir/index8.js +4 -0
- package/dist/commonjs-virtual-dir/lib-typedarrays.js +4 -0
- package/dist/commonjs-virtual-dir/md5.js +4 -0
- package/dist/commonjs-virtual-dir/mode-cfb.js +4 -0
- package/dist/commonjs-virtual-dir/mode-ctr-gladman.js +4 -0
- package/dist/commonjs-virtual-dir/mode-ctr.js +4 -0
- package/dist/commonjs-virtual-dir/mode-ecb.js +4 -0
- package/dist/commonjs-virtual-dir/mode-ofb.js +4 -0
- package/dist/commonjs-virtual-dir/pad-ansix923.js +4 -0
- package/dist/commonjs-virtual-dir/pad-iso10126.js +4 -0
- package/dist/commonjs-virtual-dir/pad-iso97971.js +4 -0
- package/dist/commonjs-virtual-dir/pad-nopadding.js +4 -0
- package/dist/commonjs-virtual-dir/pad-zeropadding.js +4 -0
- package/dist/commonjs-virtual-dir/parser.js +4 -0
- package/dist/commonjs-virtual-dir/pbkdf2.js +4 -0
- package/dist/commonjs-virtual-dir/rabbit-legacy.js +4 -0
- package/dist/commonjs-virtual-dir/rabbit.js +4 -0
- package/dist/commonjs-virtual-dir/rc4.js +4 -0
- package/dist/commonjs-virtual-dir/ripemd160.js +4 -0
- package/dist/commonjs-virtual-dir/sha1.js +4 -0
- package/dist/commonjs-virtual-dir/sha224.js +4 -0
- package/dist/commonjs-virtual-dir/sha256.js +4 -0
- package/dist/commonjs-virtual-dir/sha3.js +4 -0
- package/dist/commonjs-virtual-dir/sha384.js +4 -0
- package/dist/commonjs-virtual-dir/sha512.js +4 -0
- package/dist/commonjs-virtual-dir/tripledes.js +4 -0
- package/dist/commonjs-virtual-dir/x64-core.js +4 -0
- package/dist/main.js +25 -0
- package/dist/src/outside-call/CallManagement.js +249 -0
- package/dist/src/outside-call/constants.js +42 -0
- package/dist/src/outside-call/index.js +74 -0
- package/dist/src/outside-call/utils.js +50 -0
- package/dist/src/shield/crypto.js +28 -0
- package/dist/src/shield/index.js +59 -0
- package/dist/src/shield/no-debugger.js +26 -0
- package/dist/src/utils/eventBus.js +59 -0
- package/dist/src/vite-plugins/getCompatibilityPlugins.js +13 -0
- package/dist/src/vite-plugins/vitePluginCompatibilityDetection.js +28 -0
- package/dist/vendor/base64-js/index.js +52 -0
- package/dist/vendor/crypto-js/aes.js +69 -0
- package/dist/vendor/crypto-js/blowfish.js +1131 -0
- package/dist/vendor/crypto-js/cipher-core.js +544 -0
- package/dist/vendor/crypto-js/core.js +508 -0
- package/dist/vendor/crypto-js/enc-base64.js +80 -0
- package/dist/vendor/crypto-js/enc-base64url.js +87 -0
- package/dist/vendor/crypto-js/enc-utf16.js +99 -0
- package/dist/vendor/crypto-js/evpkdf.js +70 -0
- package/dist/vendor/crypto-js/format-hex.js +53 -0
- package/dist/vendor/crypto-js/hmac.js +83 -0
- package/dist/vendor/crypto-js/index.js +49 -0
- package/dist/vendor/crypto-js/lib-typedarrays.js +27 -0
- package/dist/vendor/crypto-js/md5.js +71 -0
- package/dist/vendor/crypto-js/mode-cfb.js +36 -0
- package/dist/vendor/crypto-js/mode-ctr-gladman.js +45 -0
- package/dist/vendor/crypto-js/mode-ctr.js +28 -0
- package/dist/vendor/crypto-js/mode-ecb.js +27 -0
- package/dist/vendor/crypto-js/mode-ofb.js +26 -0
- package/dist/vendor/crypto-js/pad-ansix923.js +25 -0
- package/dist/vendor/crypto-js/pad-iso10126.js +25 -0
- package/dist/vendor/crypto-js/pad-iso97971.js +23 -0
- package/dist/vendor/crypto-js/pad-nopadding.js +21 -0
- package/dist/vendor/crypto-js/pad-zeropadding.js +28 -0
- package/dist/vendor/crypto-js/pbkdf2.js +74 -0
- package/dist/vendor/crypto-js/rabbit-legacy.js +73 -0
- package/dist/vendor/crypto-js/rabbit.js +75 -0
- package/dist/vendor/crypto-js/rc4.js +63 -0
- package/dist/vendor/crypto-js/ripemd160.js +398 -0
- package/dist/vendor/crypto-js/sha1.js +49 -0
- package/dist/vendor/crypto-js/sha224.js +36 -0
- package/dist/vendor/crypto-js/sha256.js +57 -0
- package/dist/vendor/crypto-js/sha3.js +116 -0
- package/dist/vendor/crypto-js/sha384.js +37 -0
- package/dist/vendor/crypto-js/sha512.js +147 -0
- package/dist/vendor/crypto-js/tripledes.js +729 -0
- package/dist/vendor/crypto-js/x64-core.js +235 -0
- package/dist/vendor/debug/src/browser.js +146 -0
- package/dist/vendor/debug/src/common.js +97 -0
- package/dist/vendor/events/events.js +216 -0
- package/dist/vendor/gm-crypt/index.js +10 -0
- package/dist/vendor/gm-crypt/src/crypt.js +60 -0
- package/dist/vendor/gm-crypt/src/sm4.js +513 -0
- package/dist/vendor/jsbn/index.js +714 -0
- package/dist/vendor/jssip/lib/Constants.js +180 -0
- package/dist/vendor/jssip/lib-es5/Config.js +263 -0
- package/dist/vendor/jssip/lib-es5/Constants.js +180 -0
- package/dist/vendor/jssip/lib-es5/Dialog/RequestSender.js +84 -0
- package/dist/vendor/jssip/lib-es5/Dialog.js +179 -0
- package/dist/vendor/jssip/lib-es5/DigestAuthentication.js +93 -0
- package/dist/vendor/jssip/lib-es5/Exceptions.js +131 -0
- package/dist/vendor/jssip/lib-es5/Grammar.js +1937 -0
- package/dist/vendor/jssip/lib-es5/JsSIP.js +37 -0
- package/dist/vendor/jssip/lib-es5/Logger.js +44 -0
- package/dist/vendor/jssip/lib-es5/Message.js +229 -0
- package/dist/vendor/jssip/lib-es5/NameAddrHeader.js +107 -0
- package/dist/vendor/jssip/lib-es5/Options.js +227 -0
- package/dist/vendor/jssip/lib-es5/Parser.js +202 -0
- package/dist/vendor/jssip/lib-es5/RTCSession/DTMF.js +175 -0
- package/dist/vendor/jssip/lib-es5/RTCSession/Info.js +149 -0
- package/dist/vendor/jssip/lib-es5/RTCSession/ReferNotifier.js +52 -0
- package/dist/vendor/jssip/lib-es5/RTCSession/ReferSubscriber.js +187 -0
- package/dist/vendor/jssip/lib-es5/RTCSession.js +1799 -0
- package/dist/vendor/jssip/lib-es5/Registrator.js +194 -0
- package/dist/vendor/jssip/lib-es5/RequestSender.js +99 -0
- package/dist/vendor/jssip/lib-es5/SIPMessage.js +623 -0
- package/dist/vendor/jssip/lib-es5/Socket.js +38 -0
- package/dist/vendor/jssip/lib-es5/Timers.js +25 -0
- package/dist/vendor/jssip/lib-es5/Transactions.js +481 -0
- package/dist/vendor/jssip/lib-es5/Transport.js +220 -0
- package/dist/vendor/jssip/lib-es5/UA.js +663 -0
- package/dist/vendor/jssip/lib-es5/URI.js +221 -0
- package/dist/vendor/jssip/lib-es5/Utils.js +263 -0
- package/dist/vendor/jssip/lib-es5/WebSocketInterface.js +120 -0
- package/dist/vendor/jssip/lib-es5/sanityCheck.js +170 -0
- package/dist/vendor/jssip/package.json.js +9 -0
- package/dist/vendor/ms/index.js +85 -0
- package/dist/vendor/sdp-transform/lib/grammar.js +449 -0
- package/dist/vendor/sdp-transform/lib/index.js +14 -0
- package/dist/vendor/sdp-transform/lib/parser.js +70 -0
- package/dist/vendor/sdp-transform/lib/writer.js +74 -0
- package/dist/vendor/sm-crypto/src/index.js +14 -0
- package/dist/vendor/sm-crypto/src/sm2/asn1.js +86 -0
- package/dist/vendor/sm-crypto/src/sm2/ec.js +205 -0
- package/dist/vendor/sm-crypto/src/sm2/index.js +114 -0
- package/dist/vendor/sm-crypto/src/sm2/sm3.js +71 -0
- package/dist/vendor/sm-crypto/src/sm2/utils.js +95 -0
- package/dist/vendor/sm-crypto/src/sm3/index.js +50 -0
- package/dist/vendor/sm-crypto/src/sm4/index.js +408 -0
- package/dist/vite-plugins/index.d.ts +1 -1
- package/dist/vite-plugins/index.js +6 -0
- package/package.json +6 -5
- package/dist/index.es.js +0 -18159
- package/dist/vite-plugins/index.es.js +0 -33
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
import { __require as w } from "../../events/events.js";
|
|
2
|
+
import { __require as K } from "./Logger.js";
|
|
3
|
+
import { __require as V } from "./Constants.js";
|
|
4
|
+
import { __require as x } from "./SIPMessage.js";
|
|
5
|
+
import { __require as B } from "./Timers.js";
|
|
6
|
+
var g, P;
|
|
7
|
+
function Q() {
|
|
8
|
+
if (P) return g;
|
|
9
|
+
P = 1;
|
|
10
|
+
function C(c) {
|
|
11
|
+
"@babel/helpers - typeof";
|
|
12
|
+
return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? C = function(n) {
|
|
13
|
+
return typeof n;
|
|
14
|
+
} : C = function(n) {
|
|
15
|
+
return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
|
|
16
|
+
}, C(c);
|
|
17
|
+
}
|
|
18
|
+
function f(c, a) {
|
|
19
|
+
if (!(c instanceof a))
|
|
20
|
+
throw new TypeError("Cannot call a class as a function");
|
|
21
|
+
}
|
|
22
|
+
function U(c, a) {
|
|
23
|
+
for (var n = 0; n < a.length; n++) {
|
|
24
|
+
var t = a[n];
|
|
25
|
+
t.enumerable = t.enumerable || !1, t.configurable = !0, "value" in t && (t.writable = !0), Object.defineProperty(c, t.key, t);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function l(c, a, n) {
|
|
29
|
+
return a && U(c.prototype, a), c;
|
|
30
|
+
}
|
|
31
|
+
function _(c, a) {
|
|
32
|
+
if (typeof a != "function" && a !== null)
|
|
33
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
34
|
+
c.prototype = Object.create(a && a.prototype, { constructor: { value: c, writable: !0, configurable: !0 } }), a && m(c, a);
|
|
35
|
+
}
|
|
36
|
+
function m(c, a) {
|
|
37
|
+
return m = Object.setPrototypeOf || function(t, r) {
|
|
38
|
+
return t.__proto__ = r, t;
|
|
39
|
+
}, m(c, a);
|
|
40
|
+
}
|
|
41
|
+
function v(c) {
|
|
42
|
+
var a = D();
|
|
43
|
+
return function() {
|
|
44
|
+
var t = p(c), r;
|
|
45
|
+
if (a) {
|
|
46
|
+
var o = p(this).constructor;
|
|
47
|
+
r = Reflect.construct(t, arguments, o);
|
|
48
|
+
} else
|
|
49
|
+
r = t.apply(this, arguments);
|
|
50
|
+
return b(this, r);
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function b(c, a) {
|
|
54
|
+
return a && (C(a) === "object" || typeof a == "function") ? a : u(c);
|
|
55
|
+
}
|
|
56
|
+
function u(c) {
|
|
57
|
+
if (c === void 0)
|
|
58
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
59
|
+
return c;
|
|
60
|
+
}
|
|
61
|
+
function D() {
|
|
62
|
+
if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
|
|
63
|
+
if (typeof Proxy == "function") return !0;
|
|
64
|
+
try {
|
|
65
|
+
return Date.prototype.toString.call(Reflect.construct(Date, [], function() {
|
|
66
|
+
})), !0;
|
|
67
|
+
} catch {
|
|
68
|
+
return !1;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function p(c) {
|
|
72
|
+
return p = Object.setPrototypeOf ? Object.getPrototypeOf : function(n) {
|
|
73
|
+
return n.__proto__ || Object.getPrototypeOf(n);
|
|
74
|
+
}, p(c);
|
|
75
|
+
}
|
|
76
|
+
var d = w().EventEmitter, E = K(), S = V(), R = x(), h = B(), y = new E("NonInviteClientTransaction"), I = new E("InviteClientTransaction"), k = new E("AckClientTransaction"), N = new E("NonInviteServerTransaction"), A = new E("InviteServerTransaction"), e = {
|
|
77
|
+
// Transaction states.
|
|
78
|
+
STATUS_TRYING: 1,
|
|
79
|
+
STATUS_PROCEEDING: 2,
|
|
80
|
+
STATUS_CALLING: 3,
|
|
81
|
+
STATUS_ACCEPTED: 4,
|
|
82
|
+
STATUS_COMPLETED: 5,
|
|
83
|
+
STATUS_TERMINATED: 6,
|
|
84
|
+
STATUS_CONFIRMED: 7,
|
|
85
|
+
// Transaction types.
|
|
86
|
+
NON_INVITE_CLIENT: "nict",
|
|
87
|
+
NON_INVITE_SERVER: "nist",
|
|
88
|
+
INVITE_CLIENT: "ict",
|
|
89
|
+
INVITE_SERVER: "ist"
|
|
90
|
+
}, O = /* @__PURE__ */ function(c) {
|
|
91
|
+
_(n, c);
|
|
92
|
+
var a = v(n);
|
|
93
|
+
function n(t, r, o, i) {
|
|
94
|
+
var s;
|
|
95
|
+
f(this, n), s = a.call(this), s.type = e.NON_INVITE_CLIENT, s.id = "z9hG4bK".concat(Math.floor(Math.random() * 1e7)), s.ua = t, s.transport = r, s.request = o, s.eventHandlers = i;
|
|
96
|
+
var T = "SIP/2.0/".concat(r.via_transport);
|
|
97
|
+
return T += " ".concat(t.configuration.via_host, ";branch=").concat(s.id), s.request.setHeader("via", T), s.ua.newTransaction(u(s)), s;
|
|
98
|
+
}
|
|
99
|
+
return l(n, [{
|
|
100
|
+
key: "stateChanged",
|
|
101
|
+
value: function(r) {
|
|
102
|
+
this.state = r, this.emit("stateChanged");
|
|
103
|
+
}
|
|
104
|
+
}, {
|
|
105
|
+
key: "send",
|
|
106
|
+
value: function() {
|
|
107
|
+
var r = this;
|
|
108
|
+
this.stateChanged(e.STATUS_TRYING), this.F = setTimeout(function() {
|
|
109
|
+
r.timer_F();
|
|
110
|
+
}, h.TIMER_F), this.transport.send(this.request) || this.onTransportError();
|
|
111
|
+
}
|
|
112
|
+
}, {
|
|
113
|
+
key: "onTransportError",
|
|
114
|
+
value: function() {
|
|
115
|
+
y.debug("transport error occurred, deleting transaction ".concat(this.id)), clearTimeout(this.F), clearTimeout(this.K), this.stateChanged(e.STATUS_TERMINATED), this.ua.destroyTransaction(this), this.eventHandlers.onTransportError();
|
|
116
|
+
}
|
|
117
|
+
}, {
|
|
118
|
+
key: "timer_F",
|
|
119
|
+
value: function() {
|
|
120
|
+
y.debug("Timer F expired for transaction ".concat(this.id)), this.stateChanged(e.STATUS_TERMINATED), this.ua.destroyTransaction(this), this.eventHandlers.onRequestTimeout();
|
|
121
|
+
}
|
|
122
|
+
}, {
|
|
123
|
+
key: "timer_K",
|
|
124
|
+
value: function() {
|
|
125
|
+
this.stateChanged(e.STATUS_TERMINATED), this.ua.destroyTransaction(this);
|
|
126
|
+
}
|
|
127
|
+
}, {
|
|
128
|
+
key: "receiveResponse",
|
|
129
|
+
value: function(r) {
|
|
130
|
+
var o = this, i = r.status_code;
|
|
131
|
+
if (i < 200)
|
|
132
|
+
switch (this.state) {
|
|
133
|
+
case e.STATUS_TRYING:
|
|
134
|
+
case e.STATUS_PROCEEDING:
|
|
135
|
+
this.stateChanged(e.STATUS_PROCEEDING), this.eventHandlers.onReceiveResponse(r);
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
else
|
|
139
|
+
switch (this.state) {
|
|
140
|
+
case e.STATUS_TRYING:
|
|
141
|
+
case e.STATUS_PROCEEDING:
|
|
142
|
+
this.stateChanged(e.STATUS_COMPLETED), clearTimeout(this.F), i === 408 ? this.eventHandlers.onRequestTimeout() : this.eventHandlers.onReceiveResponse(r), this.K = setTimeout(function() {
|
|
143
|
+
o.timer_K();
|
|
144
|
+
}, h.TIMER_K);
|
|
145
|
+
break;
|
|
146
|
+
case e.STATUS_COMPLETED:
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}, {
|
|
151
|
+
key: "C",
|
|
152
|
+
get: function() {
|
|
153
|
+
return e;
|
|
154
|
+
}
|
|
155
|
+
}]), n;
|
|
156
|
+
}(d), M = /* @__PURE__ */ function(c) {
|
|
157
|
+
_(n, c);
|
|
158
|
+
var a = v(n);
|
|
159
|
+
function n(t, r, o, i) {
|
|
160
|
+
var s;
|
|
161
|
+
f(this, n), s = a.call(this), s.type = e.INVITE_CLIENT, s.id = "z9hG4bK".concat(Math.floor(Math.random() * 1e7)), s.ua = t, s.transport = r, s.request = o, s.eventHandlers = i, o.transaction = u(s);
|
|
162
|
+
var T = "SIP/2.0/".concat(r.via_transport);
|
|
163
|
+
return T += " ".concat(t.configuration.via_host, ";branch=").concat(s.id), s.request.setHeader("via", T), s.ua.newTransaction(u(s)), s;
|
|
164
|
+
}
|
|
165
|
+
return l(n, [{
|
|
166
|
+
key: "stateChanged",
|
|
167
|
+
value: function(r) {
|
|
168
|
+
this.state = r, this.emit("stateChanged");
|
|
169
|
+
}
|
|
170
|
+
}, {
|
|
171
|
+
key: "send",
|
|
172
|
+
value: function() {
|
|
173
|
+
var r = this;
|
|
174
|
+
this.stateChanged(e.STATUS_CALLING), this.B = setTimeout(function() {
|
|
175
|
+
r.timer_B();
|
|
176
|
+
}, h.TIMER_B), this.transport.send(this.request) || this.onTransportError();
|
|
177
|
+
}
|
|
178
|
+
}, {
|
|
179
|
+
key: "onTransportError",
|
|
180
|
+
value: function() {
|
|
181
|
+
clearTimeout(this.B), clearTimeout(this.D), clearTimeout(this.M), this.state !== e.STATUS_ACCEPTED && (I.debug("transport error occurred, deleting transaction ".concat(this.id)), this.eventHandlers.onTransportError()), this.stateChanged(e.STATUS_TERMINATED), this.ua.destroyTransaction(this);
|
|
182
|
+
}
|
|
183
|
+
// RFC 6026 7.2.
|
|
184
|
+
}, {
|
|
185
|
+
key: "timer_M",
|
|
186
|
+
value: function() {
|
|
187
|
+
I.debug("Timer M expired for transaction ".concat(this.id)), this.state === e.STATUS_ACCEPTED && (clearTimeout(this.B), this.stateChanged(e.STATUS_TERMINATED), this.ua.destroyTransaction(this));
|
|
188
|
+
}
|
|
189
|
+
// RFC 3261 17.1.1.
|
|
190
|
+
}, {
|
|
191
|
+
key: "timer_B",
|
|
192
|
+
value: function() {
|
|
193
|
+
I.debug("Timer B expired for transaction ".concat(this.id)), this.state === e.STATUS_CALLING && (this.stateChanged(e.STATUS_TERMINATED), this.ua.destroyTransaction(this), this.eventHandlers.onRequestTimeout());
|
|
194
|
+
}
|
|
195
|
+
}, {
|
|
196
|
+
key: "timer_D",
|
|
197
|
+
value: function() {
|
|
198
|
+
I.debug("Timer D expired for transaction ".concat(this.id)), clearTimeout(this.B), this.stateChanged(e.STATUS_TERMINATED), this.ua.destroyTransaction(this);
|
|
199
|
+
}
|
|
200
|
+
}, {
|
|
201
|
+
key: "sendACK",
|
|
202
|
+
value: function(r) {
|
|
203
|
+
var o = this, i = new R.OutgoingRequest(S.ACK, this.request.ruri, this.ua, {
|
|
204
|
+
route_set: this.request.getHeaders("route"),
|
|
205
|
+
call_id: this.request.getHeader("call-id"),
|
|
206
|
+
cseq: this.request.cseq
|
|
207
|
+
});
|
|
208
|
+
i.setHeader("from", this.request.getHeader("from")), i.setHeader("via", this.request.getHeader("via")), i.setHeader("to", r.getHeader("to")), this.D = setTimeout(function() {
|
|
209
|
+
o.timer_D();
|
|
210
|
+
}, h.TIMER_D), this.transport.send(i);
|
|
211
|
+
}
|
|
212
|
+
}, {
|
|
213
|
+
key: "cancel",
|
|
214
|
+
value: function(r) {
|
|
215
|
+
if (this.state === e.STATUS_PROCEEDING) {
|
|
216
|
+
var o = new R.OutgoingRequest(S.CANCEL, this.request.ruri, this.ua, {
|
|
217
|
+
route_set: this.request.getHeaders("route"),
|
|
218
|
+
call_id: this.request.getHeader("call-id"),
|
|
219
|
+
cseq: this.request.cseq
|
|
220
|
+
});
|
|
221
|
+
o.setHeader("from", this.request.getHeader("from")), o.setHeader("via", this.request.getHeader("via")), o.setHeader("to", this.request.getHeader("to")), r && o.setHeader("reason", r), this.transport.send(o);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}, {
|
|
225
|
+
key: "receiveResponse",
|
|
226
|
+
value: function(r) {
|
|
227
|
+
var o = this, i = r.status_code;
|
|
228
|
+
if (i >= 100 && i <= 199)
|
|
229
|
+
switch (this.state) {
|
|
230
|
+
case e.STATUS_CALLING:
|
|
231
|
+
this.stateChanged(e.STATUS_PROCEEDING), this.eventHandlers.onReceiveResponse(r);
|
|
232
|
+
break;
|
|
233
|
+
case e.STATUS_PROCEEDING:
|
|
234
|
+
this.eventHandlers.onReceiveResponse(r);
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
else if (i >= 200 && i <= 299)
|
|
238
|
+
switch (this.state) {
|
|
239
|
+
case e.STATUS_CALLING:
|
|
240
|
+
case e.STATUS_PROCEEDING:
|
|
241
|
+
this.stateChanged(e.STATUS_ACCEPTED), this.M = setTimeout(function() {
|
|
242
|
+
o.timer_M();
|
|
243
|
+
}, h.TIMER_M), this.eventHandlers.onReceiveResponse(r);
|
|
244
|
+
break;
|
|
245
|
+
case e.STATUS_ACCEPTED:
|
|
246
|
+
this.eventHandlers.onReceiveResponse(r);
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
else if (i >= 300 && i <= 699)
|
|
250
|
+
switch (this.state) {
|
|
251
|
+
case e.STATUS_CALLING:
|
|
252
|
+
case e.STATUS_PROCEEDING:
|
|
253
|
+
this.stateChanged(e.STATUS_COMPLETED), this.sendACK(r), this.eventHandlers.onReceiveResponse(r);
|
|
254
|
+
break;
|
|
255
|
+
case e.STATUS_COMPLETED:
|
|
256
|
+
this.sendACK(r);
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}, {
|
|
261
|
+
key: "C",
|
|
262
|
+
get: function() {
|
|
263
|
+
return e;
|
|
264
|
+
}
|
|
265
|
+
}]), n;
|
|
266
|
+
}(d), H = /* @__PURE__ */ function(c) {
|
|
267
|
+
_(n, c);
|
|
268
|
+
var a = v(n);
|
|
269
|
+
function n(t, r, o, i) {
|
|
270
|
+
var s;
|
|
271
|
+
f(this, n), s = a.call(this), s.id = "z9hG4bK".concat(Math.floor(Math.random() * 1e7)), s.transport = r, s.request = o, s.eventHandlers = i;
|
|
272
|
+
var T = "SIP/2.0/".concat(r.via_transport);
|
|
273
|
+
return T += " ".concat(t.configuration.via_host, ";branch=").concat(s.id), s.request.setHeader("via", T), s;
|
|
274
|
+
}
|
|
275
|
+
return l(n, [{
|
|
276
|
+
key: "send",
|
|
277
|
+
value: function() {
|
|
278
|
+
this.transport.send(this.request) || this.onTransportError();
|
|
279
|
+
}
|
|
280
|
+
}, {
|
|
281
|
+
key: "onTransportError",
|
|
282
|
+
value: function() {
|
|
283
|
+
k.debug("transport error occurred for transaction ".concat(this.id)), this.eventHandlers.onTransportError();
|
|
284
|
+
}
|
|
285
|
+
}, {
|
|
286
|
+
key: "C",
|
|
287
|
+
get: function() {
|
|
288
|
+
return e;
|
|
289
|
+
}
|
|
290
|
+
}]), n;
|
|
291
|
+
}(d), L = /* @__PURE__ */ function(c) {
|
|
292
|
+
_(n, c);
|
|
293
|
+
var a = v(n);
|
|
294
|
+
function n(t, r, o) {
|
|
295
|
+
var i;
|
|
296
|
+
return f(this, n), i = a.call(this), i.type = e.NON_INVITE_SERVER, i.id = o.via_branch, i.ua = t, i.transport = r, i.request = o, i.last_response = "", o.server_transaction = u(i), i.state = e.STATUS_TRYING, t.newTransaction(u(i)), i;
|
|
297
|
+
}
|
|
298
|
+
return l(n, [{
|
|
299
|
+
key: "stateChanged",
|
|
300
|
+
value: function(r) {
|
|
301
|
+
this.state = r, this.emit("stateChanged");
|
|
302
|
+
}
|
|
303
|
+
}, {
|
|
304
|
+
key: "timer_J",
|
|
305
|
+
value: function() {
|
|
306
|
+
N.debug("Timer J expired for transaction ".concat(this.id)), this.stateChanged(e.STATUS_TERMINATED), this.ua.destroyTransaction(this);
|
|
307
|
+
}
|
|
308
|
+
}, {
|
|
309
|
+
key: "onTransportError",
|
|
310
|
+
value: function() {
|
|
311
|
+
this.transportError || (this.transportError = !0, N.debug("transport error occurred, deleting transaction ".concat(this.id)), clearTimeout(this.J), this.stateChanged(e.STATUS_TERMINATED), this.ua.destroyTransaction(this));
|
|
312
|
+
}
|
|
313
|
+
}, {
|
|
314
|
+
key: "receiveResponse",
|
|
315
|
+
value: function(r, o, i, s) {
|
|
316
|
+
var T = this;
|
|
317
|
+
if (r === 100)
|
|
318
|
+
switch (this.state) {
|
|
319
|
+
case e.STATUS_TRYING:
|
|
320
|
+
this.stateChanged(e.STATUS_PROCEEDING), this.transport.send(o) || this.onTransportError();
|
|
321
|
+
break;
|
|
322
|
+
case e.STATUS_PROCEEDING:
|
|
323
|
+
this.last_response = o, this.transport.send(o) ? i && i() : (this.onTransportError(), s && s());
|
|
324
|
+
break;
|
|
325
|
+
}
|
|
326
|
+
else if (r >= 200 && r <= 699)
|
|
327
|
+
switch (this.state) {
|
|
328
|
+
case e.STATUS_TRYING:
|
|
329
|
+
case e.STATUS_PROCEEDING:
|
|
330
|
+
this.stateChanged(e.STATUS_COMPLETED), this.last_response = o, this.J = setTimeout(function() {
|
|
331
|
+
T.timer_J();
|
|
332
|
+
}, h.TIMER_J), this.transport.send(o) ? i && i() : (this.onTransportError(), s && s());
|
|
333
|
+
break;
|
|
334
|
+
case e.STATUS_COMPLETED:
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}, {
|
|
339
|
+
key: "C",
|
|
340
|
+
get: function() {
|
|
341
|
+
return e;
|
|
342
|
+
}
|
|
343
|
+
}]), n;
|
|
344
|
+
}(d), G = /* @__PURE__ */ function(c) {
|
|
345
|
+
_(n, c);
|
|
346
|
+
var a = v(n);
|
|
347
|
+
function n(t, r, o) {
|
|
348
|
+
var i;
|
|
349
|
+
return f(this, n), i = a.call(this), i.type = e.INVITE_SERVER, i.id = o.via_branch, i.ua = t, i.transport = r, i.request = o, i.last_response = "", o.server_transaction = u(i), i.state = e.STATUS_PROCEEDING, t.newTransaction(u(i)), i.resendProvisionalTimer = null, o.reply(100), i;
|
|
350
|
+
}
|
|
351
|
+
return l(n, [{
|
|
352
|
+
key: "stateChanged",
|
|
353
|
+
value: function(r) {
|
|
354
|
+
this.state = r, this.emit("stateChanged");
|
|
355
|
+
}
|
|
356
|
+
}, {
|
|
357
|
+
key: "timer_H",
|
|
358
|
+
value: function() {
|
|
359
|
+
A.debug("Timer H expired for transaction ".concat(this.id)), this.state === e.STATUS_COMPLETED && A.debug("ACK not received, dialog will be terminated"), this.stateChanged(e.STATUS_TERMINATED), this.ua.destroyTransaction(this);
|
|
360
|
+
}
|
|
361
|
+
}, {
|
|
362
|
+
key: "timer_I",
|
|
363
|
+
value: function() {
|
|
364
|
+
this.stateChanged(e.STATUS_TERMINATED), this.ua.destroyTransaction(this);
|
|
365
|
+
}
|
|
366
|
+
// RFC 6026 7.1.
|
|
367
|
+
}, {
|
|
368
|
+
key: "timer_L",
|
|
369
|
+
value: function() {
|
|
370
|
+
A.debug("Timer L expired for transaction ".concat(this.id)), this.state === e.STATUS_ACCEPTED && (this.stateChanged(e.STATUS_TERMINATED), this.ua.destroyTransaction(this));
|
|
371
|
+
}
|
|
372
|
+
}, {
|
|
373
|
+
key: "onTransportError",
|
|
374
|
+
value: function() {
|
|
375
|
+
this.transportError || (this.transportError = !0, A.debug("transport error occurred, deleting transaction ".concat(this.id)), this.resendProvisionalTimer !== null && (clearInterval(this.resendProvisionalTimer), this.resendProvisionalTimer = null), clearTimeout(this.L), clearTimeout(this.H), clearTimeout(this.I), this.stateChanged(e.STATUS_TERMINATED), this.ua.destroyTransaction(this));
|
|
376
|
+
}
|
|
377
|
+
}, {
|
|
378
|
+
key: "resend_provisional",
|
|
379
|
+
value: function() {
|
|
380
|
+
this.transport.send(this.last_response) || this.onTransportError();
|
|
381
|
+
}
|
|
382
|
+
// INVITE Server Transaction RFC 3261 17.2.1.
|
|
383
|
+
}, {
|
|
384
|
+
key: "receiveResponse",
|
|
385
|
+
value: function(r, o, i, s) {
|
|
386
|
+
var T = this;
|
|
387
|
+
if (r >= 100 && r <= 199)
|
|
388
|
+
switch (this.state) {
|
|
389
|
+
case e.STATUS_PROCEEDING:
|
|
390
|
+
this.transport.send(o) || this.onTransportError(), this.last_response = o;
|
|
391
|
+
break;
|
|
392
|
+
}
|
|
393
|
+
if (r > 100 && r <= 199 && this.state === e.STATUS_PROCEEDING)
|
|
394
|
+
this.resendProvisionalTimer === null && (this.resendProvisionalTimer = setInterval(function() {
|
|
395
|
+
T.resend_provisional();
|
|
396
|
+
}, h.PROVISIONAL_RESPONSE_INTERVAL));
|
|
397
|
+
else if (r >= 200 && r <= 299)
|
|
398
|
+
switch (this.state) {
|
|
399
|
+
case e.STATUS_PROCEEDING:
|
|
400
|
+
this.stateChanged(e.STATUS_ACCEPTED), this.last_response = o, this.L = setTimeout(function() {
|
|
401
|
+
T.timer_L();
|
|
402
|
+
}, h.TIMER_L), this.resendProvisionalTimer !== null && (clearInterval(this.resendProvisionalTimer), this.resendProvisionalTimer = null);
|
|
403
|
+
/* falls through */
|
|
404
|
+
case e.STATUS_ACCEPTED:
|
|
405
|
+
this.transport.send(o) ? i && i() : (this.onTransportError(), s && s());
|
|
406
|
+
break;
|
|
407
|
+
}
|
|
408
|
+
else if (r >= 300 && r <= 699)
|
|
409
|
+
switch (this.state) {
|
|
410
|
+
case e.STATUS_PROCEEDING:
|
|
411
|
+
this.resendProvisionalTimer !== null && (clearInterval(this.resendProvisionalTimer), this.resendProvisionalTimer = null), this.transport.send(o) ? (this.stateChanged(e.STATUS_COMPLETED), this.H = setTimeout(function() {
|
|
412
|
+
T.timer_H();
|
|
413
|
+
}, h.TIMER_H), i && i()) : (this.onTransportError(), s && s());
|
|
414
|
+
break;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}, {
|
|
418
|
+
key: "C",
|
|
419
|
+
get: function() {
|
|
420
|
+
return e;
|
|
421
|
+
}
|
|
422
|
+
}]), n;
|
|
423
|
+
}(d);
|
|
424
|
+
function q(c, a) {
|
|
425
|
+
var n = c._transactions, t;
|
|
426
|
+
switch (a.method) {
|
|
427
|
+
case S.INVITE:
|
|
428
|
+
if (t = n.ist[a.via_branch], t) {
|
|
429
|
+
switch (t.state) {
|
|
430
|
+
case e.STATUS_PROCEEDING:
|
|
431
|
+
t.transport.send(t.last_response);
|
|
432
|
+
break;
|
|
433
|
+
// RFC 6026 7.1 Invite retransmission.
|
|
434
|
+
// Received while in C.STATUS_ACCEPTED state. Absorb it.
|
|
435
|
+
case e.STATUS_ACCEPTED:
|
|
436
|
+
break;
|
|
437
|
+
}
|
|
438
|
+
return !0;
|
|
439
|
+
}
|
|
440
|
+
break;
|
|
441
|
+
case S.ACK:
|
|
442
|
+
if (t = n.ist[a.via_branch], t) {
|
|
443
|
+
if (t.state === e.STATUS_ACCEPTED)
|
|
444
|
+
return !1;
|
|
445
|
+
if (t.state === e.STATUS_COMPLETED)
|
|
446
|
+
return t.state = e.STATUS_CONFIRMED, t.I = setTimeout(function() {
|
|
447
|
+
t.timer_I();
|
|
448
|
+
}, h.TIMER_I), !0;
|
|
449
|
+
} else
|
|
450
|
+
return !1;
|
|
451
|
+
break;
|
|
452
|
+
case S.CANCEL:
|
|
453
|
+
return t = n.ist[a.via_branch], t ? (a.reply_sl(200), t.state !== e.STATUS_PROCEEDING) : (a.reply_sl(481), !0);
|
|
454
|
+
default:
|
|
455
|
+
if (t = n.nist[a.via_branch], t) {
|
|
456
|
+
switch (t.state) {
|
|
457
|
+
case e.STATUS_TRYING:
|
|
458
|
+
break;
|
|
459
|
+
case e.STATUS_PROCEEDING:
|
|
460
|
+
case e.STATUS_COMPLETED:
|
|
461
|
+
t.transport.send(t.last_response);
|
|
462
|
+
break;
|
|
463
|
+
}
|
|
464
|
+
return !0;
|
|
465
|
+
}
|
|
466
|
+
break;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
return g = {
|
|
470
|
+
C: e,
|
|
471
|
+
NonInviteClientTransaction: O,
|
|
472
|
+
InviteClientTransaction: M,
|
|
473
|
+
AckClientTransaction: H,
|
|
474
|
+
NonInviteServerTransaction: L,
|
|
475
|
+
InviteServerTransaction: G,
|
|
476
|
+
checkTransaction: q
|
|
477
|
+
}, g;
|
|
478
|
+
}
|
|
479
|
+
export {
|
|
480
|
+
Q as __require
|
|
481
|
+
};
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { __require as v } from "./Logger.js";
|
|
2
|
+
import { __require as T } from "./Socket.js";
|
|
3
|
+
import { __require as m } from "./Constants.js";
|
|
4
|
+
var c, h;
|
|
5
|
+
function y() {
|
|
6
|
+
if (h) return c;
|
|
7
|
+
h = 1;
|
|
8
|
+
function _(r, n) {
|
|
9
|
+
if (!(r instanceof n))
|
|
10
|
+
throw new TypeError("Cannot call a class as a function");
|
|
11
|
+
}
|
|
12
|
+
function l(r, n) {
|
|
13
|
+
for (var e = 0; e < n.length; e++) {
|
|
14
|
+
var t = n[e];
|
|
15
|
+
t.enumerable = t.enumerable || !1, t.configurable = !0, "value" in t && (t.writable = !0), Object.defineProperty(r, t.key, t);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function f(r, n, e) {
|
|
19
|
+
return n && l(r.prototype, n), r;
|
|
20
|
+
}
|
|
21
|
+
var g = v(), d = T(), a = m(), s = new g("Transport"), i = {
|
|
22
|
+
// Transport status.
|
|
23
|
+
STATUS_CONNECTED: 0,
|
|
24
|
+
STATUS_CONNECTING: 1,
|
|
25
|
+
STATUS_DISCONNECTED: 2,
|
|
26
|
+
// Socket status.
|
|
27
|
+
SOCKET_STATUS_READY: 0,
|
|
28
|
+
SOCKET_STATUS_ERROR: 1,
|
|
29
|
+
// Recovery options.
|
|
30
|
+
recovery_options: {
|
|
31
|
+
// minimum interval in seconds between recover attempts.
|
|
32
|
+
min_interval: a.CONNECTION_RECOVERY_MIN_INTERVAL,
|
|
33
|
+
// maximum interval in seconds between recover attempts.
|
|
34
|
+
max_interval: a.CONNECTION_RECOVERY_MAX_INTERVAL
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
return c = /* @__PURE__ */ function() {
|
|
38
|
+
function r(n) {
|
|
39
|
+
var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : i.recovery_options;
|
|
40
|
+
_(this, r), s.debug("new()"), this.status = i.STATUS_DISCONNECTED, this.socket = null, this.sockets = [], this.recovery_options = e, this.recover_attempts = 0, this.recovery_timer = null, this.close_requested = !1;
|
|
41
|
+
try {
|
|
42
|
+
this.textDecoder = new TextDecoder("utf8");
|
|
43
|
+
} catch (t) {
|
|
44
|
+
s.warn("cannot use TextDecoder: ".concat(t));
|
|
45
|
+
}
|
|
46
|
+
if (typeof n > "u")
|
|
47
|
+
throw new TypeError("Invalid argument. undefined 'sockets' argument");
|
|
48
|
+
n instanceof Array || (n = [n]), n.forEach(function(t) {
|
|
49
|
+
if (!d.isSocket(t.socket))
|
|
50
|
+
throw new TypeError("Invalid argument. invalid 'JsSIP.Socket' instance");
|
|
51
|
+
if (t.weight && !Number(t.weight))
|
|
52
|
+
throw new TypeError("Invalid argument. 'weight' attribute is not a number");
|
|
53
|
+
this.sockets.push({
|
|
54
|
+
socket: t.socket,
|
|
55
|
+
weight: t.weight || 0,
|
|
56
|
+
status: i.SOCKET_STATUS_READY
|
|
57
|
+
});
|
|
58
|
+
}, this), this._getSocket();
|
|
59
|
+
}
|
|
60
|
+
return f(r, [{
|
|
61
|
+
key: "connect",
|
|
62
|
+
value: function() {
|
|
63
|
+
if (s.debug("connect()"), this.isConnected()) {
|
|
64
|
+
s.debug("Transport is already connected");
|
|
65
|
+
return;
|
|
66
|
+
} else if (this.isConnecting()) {
|
|
67
|
+
s.debug("Transport is connecting");
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
this.close_requested = !1, this.status = i.STATUS_CONNECTING, this.onconnecting({
|
|
71
|
+
socket: this.socket,
|
|
72
|
+
attempts: this.recover_attempts
|
|
73
|
+
}), this.close_requested || (this.socket.onconnect = this._onConnect.bind(this), this.socket.ondisconnect = this._onDisconnect.bind(this), this.socket.ondata = this._onData.bind(this), this.socket.connect());
|
|
74
|
+
}
|
|
75
|
+
}, {
|
|
76
|
+
key: "disconnect",
|
|
77
|
+
value: function() {
|
|
78
|
+
s.debug("close()"), this.close_requested = !0, this.recover_attempts = 0, this.status = i.STATUS_DISCONNECTED, this.recovery_timer !== null && (clearTimeout(this.recovery_timer), this.recovery_timer = null), this.socket.onconnect = function() {
|
|
79
|
+
}, this.socket.ondisconnect = function() {
|
|
80
|
+
}, this.socket.ondata = function() {
|
|
81
|
+
}, this.socket.disconnect(), this.ondisconnect({
|
|
82
|
+
socket: this.socket,
|
|
83
|
+
error: !1
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}, {
|
|
87
|
+
key: "send",
|
|
88
|
+
value: function(e) {
|
|
89
|
+
if (s.debug("send()"), !this.isConnected())
|
|
90
|
+
return s.warn("unable to send message, transport is not connected"), !1;
|
|
91
|
+
var t = e.toString();
|
|
92
|
+
return s.debug(`sending message:
|
|
93
|
+
|
|
94
|
+
`.concat(t, `
|
|
95
|
+
`)), this.socket.send(t);
|
|
96
|
+
}
|
|
97
|
+
}, {
|
|
98
|
+
key: "isConnected",
|
|
99
|
+
value: function() {
|
|
100
|
+
return this.status === i.STATUS_CONNECTED;
|
|
101
|
+
}
|
|
102
|
+
}, {
|
|
103
|
+
key: "isConnecting",
|
|
104
|
+
value: function() {
|
|
105
|
+
return this.status === i.STATUS_CONNECTING;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Private API.
|
|
109
|
+
*/
|
|
110
|
+
}, {
|
|
111
|
+
key: "_reconnect",
|
|
112
|
+
value: function() {
|
|
113
|
+
var e = this;
|
|
114
|
+
this.recover_attempts += 1;
|
|
115
|
+
var t = Math.floor(Math.random() * Math.pow(2, this.recover_attempts) + 1);
|
|
116
|
+
t < this.recovery_options.min_interval ? t = this.recovery_options.min_interval : t > this.recovery_options.max_interval && (t = this.recovery_options.max_interval), s.debug("reconnection attempt: ".concat(this.recover_attempts, ". next connection attempt in ").concat(t, " seconds")), this.recovery_timer = setTimeout(function() {
|
|
117
|
+
!e.close_requested && !(e.isConnected() || e.isConnecting()) && (e._getSocket(), e.connect());
|
|
118
|
+
}, t * 1e3);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* get the next available socket with higher weight
|
|
122
|
+
*/
|
|
123
|
+
}, {
|
|
124
|
+
key: "_getSocket",
|
|
125
|
+
value: function() {
|
|
126
|
+
var e = [];
|
|
127
|
+
if (this.sockets.forEach(function(o) {
|
|
128
|
+
o.status !== i.SOCKET_STATUS_ERROR && (e.length === 0 ? e.push(o) : o.weight > e[0].weight ? e = [o] : o.weight === e[0].weight && e.push(o));
|
|
129
|
+
}), e.length === 0) {
|
|
130
|
+
this.sockets.forEach(function(o) {
|
|
131
|
+
o.status = i.SOCKET_STATUS_READY;
|
|
132
|
+
}), this._getSocket();
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
var t = Math.floor(Math.random() * e.length);
|
|
136
|
+
this.socket = e[t].socket;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Socket Event Handlers
|
|
140
|
+
*/
|
|
141
|
+
}, {
|
|
142
|
+
key: "_onConnect",
|
|
143
|
+
value: function() {
|
|
144
|
+
this.recover_attempts = 0, this.status = i.STATUS_CONNECTED, this.recovery_timer !== null && (clearTimeout(this.recovery_timer), this.recovery_timer = null), this.onconnect({
|
|
145
|
+
socket: this
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}, {
|
|
149
|
+
key: "_onDisconnect",
|
|
150
|
+
value: function(e, t, o) {
|
|
151
|
+
this.status = i.STATUS_DISCONNECTED, this.ondisconnect({
|
|
152
|
+
socket: this.socket,
|
|
153
|
+
error: e,
|
|
154
|
+
code: t,
|
|
155
|
+
reason: o
|
|
156
|
+
}), !this.close_requested && (this.sockets.forEach(function(u) {
|
|
157
|
+
this.socket === u.socket && (u.status = i.SOCKET_STATUS_ERROR);
|
|
158
|
+
}, this), this._reconnect(e));
|
|
159
|
+
}
|
|
160
|
+
}, {
|
|
161
|
+
key: "_onData",
|
|
162
|
+
value: function(e) {
|
|
163
|
+
if (e === `\r
|
|
164
|
+
\r
|
|
165
|
+
`) {
|
|
166
|
+
s.debug("received message with double-CRLF Keep Alive request");
|
|
167
|
+
try {
|
|
168
|
+
this.socket.send(`\r
|
|
169
|
+
`);
|
|
170
|
+
} catch (t) {
|
|
171
|
+
s.warn("error sending Keep Alive response: ".concat(t));
|
|
172
|
+
}
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (e === `\r
|
|
176
|
+
`) {
|
|
177
|
+
s.debug("received message with CRLF Keep Alive response");
|
|
178
|
+
return;
|
|
179
|
+
} else if (typeof e != "string") {
|
|
180
|
+
try {
|
|
181
|
+
this.textDecoder ? e = this.textDecoder.decode(e) : e = String.fromCharCode.apply(null, new Uint8Array(e));
|
|
182
|
+
} catch {
|
|
183
|
+
s.debug("received binary message failed to be converted into string, message discarded");
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
s.debug(`received binary message:
|
|
187
|
+
|
|
188
|
+
`.concat(e, `
|
|
189
|
+
`));
|
|
190
|
+
} else
|
|
191
|
+
s.debug(`received text message:
|
|
192
|
+
|
|
193
|
+
`.concat(e, `
|
|
194
|
+
`));
|
|
195
|
+
this.ondata({
|
|
196
|
+
transport: this,
|
|
197
|
+
message: e
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}, {
|
|
201
|
+
key: "via_transport",
|
|
202
|
+
get: function() {
|
|
203
|
+
return this.socket.via_transport;
|
|
204
|
+
}
|
|
205
|
+
}, {
|
|
206
|
+
key: "url",
|
|
207
|
+
get: function() {
|
|
208
|
+
return this.socket.url;
|
|
209
|
+
}
|
|
210
|
+
}, {
|
|
211
|
+
key: "sip_uri",
|
|
212
|
+
get: function() {
|
|
213
|
+
return this.socket.sip_uri;
|
|
214
|
+
}
|
|
215
|
+
}]), r;
|
|
216
|
+
}(), c;
|
|
217
|
+
}
|
|
218
|
+
export {
|
|
219
|
+
y as __require
|
|
220
|
+
};
|