podasync-ws-only 2.9.0-snapshot.7 → 2.9.0-snapshot.8
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/node/network/async.js +1 -0
- package/dist/node/network/webrtc.js +15 -5
- package/package.json +1 -1
- package/src/network/async.js +1 -0
- package/src/network/webrtc.js +48 -35
|
@@ -290,6 +290,7 @@
|
|
|
290
290
|
initWebrtc = function () {
|
|
291
291
|
webRTCClass = new WebRTCClass({
|
|
292
292
|
baseUrl: webrtcConfig ? webrtcConfig.baseUrl : null,
|
|
293
|
+
basePath: webrtcConfig ? webrtcConfig.basePath : null,
|
|
293
294
|
configuration: webrtcConfig ? webrtcConfig.configuration : null,
|
|
294
295
|
connectionCheckTimeout: params.connectionCheckTimeout,
|
|
295
296
|
logLevel: logLevel
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
let defaultConfig = {
|
|
2
|
-
|
|
2
|
+
protocol: "https",
|
|
3
|
+
baseUrl: "109.201.0.97",
|
|
4
|
+
basePath: "/webrtc/",
|
|
3
5
|
registerEndpoint: "register/",
|
|
4
6
|
addICEEndpoint: "add-ice/",
|
|
5
7
|
getICEEndpoint: "get-ice/?",
|
|
@@ -30,7 +32,8 @@ let defaultConfig = {
|
|
|
30
32
|
register: 3,
|
|
31
33
|
getIce: 3,
|
|
32
34
|
addIce: 5
|
|
33
|
-
}
|
|
35
|
+
},
|
|
36
|
+
subdomain: null
|
|
34
37
|
};
|
|
35
38
|
function CandidatesSendQueueManager() {
|
|
36
39
|
let config = {
|
|
@@ -128,6 +131,7 @@ function connect() {
|
|
|
128
131
|
function processRegisterResult(result) {
|
|
129
132
|
variables.clientId = result.clientId;
|
|
130
133
|
variables.deviceId = result.deviceId;
|
|
134
|
+
variables.subdomain = result.subDomain;
|
|
131
135
|
webrtcFunctions.processAnswer(result.sdpAnswer);
|
|
132
136
|
}
|
|
133
137
|
}
|
|
@@ -254,12 +258,15 @@ let dataChannelCallbacks = {
|
|
|
254
258
|
eventCallback["close"](event);
|
|
255
259
|
}
|
|
256
260
|
};
|
|
261
|
+
function getApiUrl() {
|
|
262
|
+
return (variables.subdomain ? variables.subdomain : defaultConfig.protocol + "://" + defaultConfig.baseUrl) + defaultConfig.basePath;
|
|
263
|
+
}
|
|
257
264
|
let handshakingFunctions = {
|
|
258
265
|
register: function (offer) {
|
|
259
266
|
let retries = variables.apiCallRetries.register;
|
|
260
267
|
return new Promise(promiseHandler);
|
|
261
268
|
function promiseHandler(resolve, reject) {
|
|
262
|
-
let registerEndPoint =
|
|
269
|
+
let registerEndPoint = getApiUrl() + defaultConfig.registerEndpoint;
|
|
263
270
|
fetch(registerEndPoint, {
|
|
264
271
|
method: "POST",
|
|
265
272
|
body: JSON.stringify({
|
|
@@ -291,7 +298,7 @@ let handshakingFunctions = {
|
|
|
291
298
|
}
|
|
292
299
|
},
|
|
293
300
|
getCandidates: function (clientId) {
|
|
294
|
-
let addIceCandidateEndPoint =
|
|
301
|
+
let addIceCandidateEndPoint = getApiUrl() + defaultConfig.getICEEndpoint;
|
|
295
302
|
addIceCandidateEndPoint += "clientId=" + clientId;
|
|
296
303
|
let retries = variables.apiCallRetries.getIce;
|
|
297
304
|
return new Promise(promiseHandler);
|
|
@@ -336,7 +343,7 @@ let handshakingFunctions = {
|
|
|
336
343
|
}
|
|
337
344
|
},
|
|
338
345
|
sendCandidate: function (candidate) {
|
|
339
|
-
let addIceCandidateEndPoint =
|
|
346
|
+
let addIceCandidateEndPoint = getApiUrl() + defaultConfig.addICEEndpoint,
|
|
340
347
|
retries = variables.apiCallRetries.addIce;
|
|
341
348
|
return new Promise(promiseHandler);
|
|
342
349
|
function promiseHandler(resolve, reject) {
|
|
@@ -376,6 +383,7 @@ eventCallback = {};
|
|
|
376
383
|
function resetVariables() {
|
|
377
384
|
console.log("resetVariables");
|
|
378
385
|
eventCallback["close"]();
|
|
386
|
+
variables.subdomain = null;
|
|
379
387
|
variables.pingController.stopPingLoop();
|
|
380
388
|
variables.dataChannel && variables.dataChannel.close();
|
|
381
389
|
variables.dataChannel = null;
|
|
@@ -403,12 +411,14 @@ function removeCallbacks() {
|
|
|
403
411
|
}
|
|
404
412
|
function WebRTCClass({
|
|
405
413
|
baseUrl,
|
|
414
|
+
basePath,
|
|
406
415
|
configuration,
|
|
407
416
|
connectionCheckTimeout = 10000,
|
|
408
417
|
logLevel
|
|
409
418
|
}) {
|
|
410
419
|
let config = {};
|
|
411
420
|
if (baseUrl) config.baseUrl = baseUrl;
|
|
421
|
+
if (basePath) config.basePath = basePath;
|
|
412
422
|
if (configuration) config.configuration = configuration;
|
|
413
423
|
if (connectionCheckTimeout) config.connectionCheckTimeout = connectionCheckTimeout;
|
|
414
424
|
if (logLevel) config.logLevel = logLevel;
|
package/package.json
CHANGED
package/src/network/async.js
CHANGED
|
@@ -320,6 +320,7 @@
|
|
|
320
320
|
initWebrtc = function () {
|
|
321
321
|
webRTCClass = new WebRTCClass({
|
|
322
322
|
baseUrl: (webrtcConfig ? webrtcConfig.baseUrl : null),
|
|
323
|
+
basePath: (webrtcConfig ? webrtcConfig.basePath : null),
|
|
323
324
|
configuration : (webrtcConfig ? webrtcConfig.configuration : null),
|
|
324
325
|
connectionCheckTimeout: params.connectionCheckTimeout,
|
|
325
326
|
logLevel: logLevel
|
package/src/network/webrtc.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
let defaultConfig = {
|
|
2
|
-
|
|
2
|
+
protocol: "https",
|
|
3
|
+
baseUrl: "109.201.0.97",
|
|
4
|
+
basePath: "/webrtc/",
|
|
3
5
|
registerEndpoint: "register/",
|
|
4
6
|
addICEEndpoint: "add-ice/",
|
|
5
7
|
getICEEndpoint: "get-ice/?",
|
|
@@ -26,7 +28,8 @@ let defaultConfig = {
|
|
|
26
28
|
register: 3,
|
|
27
29
|
getIce: 3,
|
|
28
30
|
addIce: 5
|
|
29
|
-
}
|
|
31
|
+
},
|
|
32
|
+
subdomain: null
|
|
30
33
|
};
|
|
31
34
|
|
|
32
35
|
function CandidatesSendQueueManager() {
|
|
@@ -143,6 +146,7 @@ function connect() {
|
|
|
143
146
|
function processRegisterResult(result) {
|
|
144
147
|
variables.clientId = result.clientId;
|
|
145
148
|
variables.deviceId = result.deviceId;
|
|
149
|
+
variables.subdomain = result.subDomain;
|
|
146
150
|
webrtcFunctions.processAnswer(result.sdpAnswer);
|
|
147
151
|
}
|
|
148
152
|
}
|
|
@@ -274,12 +278,16 @@ let dataChannelCallbacks = {
|
|
|
274
278
|
}
|
|
275
279
|
}
|
|
276
280
|
|
|
281
|
+
function getApiUrl() {
|
|
282
|
+
return (variables.subdomain ? variables.subdomain : defaultConfig.protocol + "://" + defaultConfig.baseUrl) + defaultConfig.basePath;
|
|
283
|
+
}
|
|
284
|
+
|
|
277
285
|
let handshakingFunctions = {
|
|
278
286
|
register: function (offer) {
|
|
279
287
|
let retries = variables.apiCallRetries.register;
|
|
280
288
|
return new Promise(promiseHandler);
|
|
281
289
|
function promiseHandler(resolve, reject) {
|
|
282
|
-
let registerEndPoint =
|
|
290
|
+
let registerEndPoint = getApiUrl() + defaultConfig.registerEndpoint
|
|
283
291
|
fetch(registerEndPoint, {
|
|
284
292
|
method: "POST",
|
|
285
293
|
body: JSON.stringify({
|
|
@@ -314,7 +322,7 @@ let handshakingFunctions = {
|
|
|
314
322
|
}
|
|
315
323
|
},
|
|
316
324
|
getCandidates: function (clientId) {
|
|
317
|
-
let addIceCandidateEndPoint =
|
|
325
|
+
let addIceCandidateEndPoint = getApiUrl() + defaultConfig.getICEEndpoint
|
|
318
326
|
addIceCandidateEndPoint += "clientId=" + clientId;
|
|
319
327
|
|
|
320
328
|
let retries = variables.apiCallRetries.getIce;
|
|
@@ -327,36 +335,36 @@ let handshakingFunctions = {
|
|
|
327
335
|
// 'Content-Type': 'application/x-www-form-urlencoded',
|
|
328
336
|
},
|
|
329
337
|
})
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
338
|
+
.then(function (response) {
|
|
339
|
+
if(response.ok)
|
|
340
|
+
return response.json();
|
|
341
|
+
else if(retries){
|
|
342
|
+
retryTheRequest(resolve, reject);
|
|
343
|
+
retries--;
|
|
344
|
+
} else reject();
|
|
345
|
+
})
|
|
346
|
+
.then(function (result) {
|
|
347
|
+
resolve(result.iceCandidates)
|
|
348
|
+
// if(result.iceCandidates && result.iceCandidates.length) {
|
|
349
|
+
// // result.iceCandidates.forEach((item) => {
|
|
350
|
+
// // webrtcFunctions.putCandidateToQueue(item);
|
|
351
|
+
// // });
|
|
352
|
+
// resolve(result.iceCandidates)
|
|
353
|
+
// }
|
|
354
|
+
// else {
|
|
355
|
+
// if(retries){
|
|
356
|
+
// retryTheRequest(resolve, reject);
|
|
357
|
+
// retries--;
|
|
358
|
+
// } else reject();
|
|
359
|
+
// }
|
|
360
|
+
})
|
|
361
|
+
.catch(function (err) {
|
|
362
|
+
if(retries){
|
|
363
|
+
retryTheRequest(resolve, reject);
|
|
364
|
+
retries--;
|
|
365
|
+
} else reject(err);
|
|
366
|
+
console.error(err);
|
|
367
|
+
});
|
|
360
368
|
}
|
|
361
369
|
|
|
362
370
|
function retryTheRequest(resolve, reject){
|
|
@@ -365,7 +373,7 @@ let handshakingFunctions = {
|
|
|
365
373
|
|
|
366
374
|
},
|
|
367
375
|
sendCandidate: function (candidate) {
|
|
368
|
-
let addIceCandidateEndPoint =
|
|
376
|
+
let addIceCandidateEndPoint = getApiUrl() + defaultConfig.addICEEndpoint
|
|
369
377
|
, retries = variables.apiCallRetries.addIce;
|
|
370
378
|
|
|
371
379
|
return new Promise(promiseHandler);
|
|
@@ -412,6 +420,7 @@ eventCallback = {};
|
|
|
412
420
|
function resetVariables() {
|
|
413
421
|
console.log("resetVariables");
|
|
414
422
|
eventCallback["close"]();
|
|
423
|
+
variables.subdomain = null;
|
|
415
424
|
variables.pingController.stopPingLoop();
|
|
416
425
|
variables.dataChannel && variables.dataChannel.close();
|
|
417
426
|
variables.dataChannel = null;
|
|
@@ -442,6 +451,7 @@ function removeCallbacks(){
|
|
|
442
451
|
|
|
443
452
|
function WebRTCClass({
|
|
444
453
|
baseUrl,
|
|
454
|
+
basePath,
|
|
445
455
|
configuration,
|
|
446
456
|
connectionCheckTimeout = 10000,
|
|
447
457
|
logLevel
|
|
@@ -449,6 +459,9 @@ function WebRTCClass({
|
|
|
449
459
|
let config = {}
|
|
450
460
|
if (baseUrl)
|
|
451
461
|
config.baseUrl = baseUrl;
|
|
462
|
+
if (basePath)
|
|
463
|
+
config.basePath = basePath;
|
|
464
|
+
|
|
452
465
|
if (configuration)
|
|
453
466
|
config.configuration = configuration;
|
|
454
467
|
if (connectionCheckTimeout)
|