podasync-ws-only 2.8.1-snapshot.0 → 2.9.0-snapshot.2
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/package.json +1 -1
- package/src/network/async.js +28 -10
- package/src/network/webrtc.js +23 -8
package/package.json
CHANGED
package/src/network/async.js
CHANGED
|
@@ -66,16 +66,16 @@
|
|
|
66
66
|
CLOSED: 3 // The connection is closed or couldn't be opened.
|
|
67
67
|
},
|
|
68
68
|
logLevel = LogLevel(params.logLevel),
|
|
69
|
-
isNode = Utility.isNode(),
|
|
69
|
+
// isNode = Utility.isNode(),
|
|
70
70
|
isSocketOpen = false,
|
|
71
71
|
isDeviceRegister = false,
|
|
72
72
|
isServerRegister = false,
|
|
73
73
|
socketState = socketStateType.CONNECTING,
|
|
74
|
-
asyncState = '',
|
|
74
|
+
// asyncState = '',
|
|
75
75
|
registerServerTimeoutId,
|
|
76
76
|
registerDeviceTimeoutId,
|
|
77
77
|
checkIfSocketHasOpennedTimeoutId,
|
|
78
|
-
asyncReadyTimeoutId,
|
|
78
|
+
// asyncReadyTimeoutId,
|
|
79
79
|
pushSendDataQueue = [],
|
|
80
80
|
oldPeerId,
|
|
81
81
|
peerId = params.peerId,
|
|
@@ -884,14 +884,32 @@
|
|
|
884
884
|
else if(protocol == "webrtc")
|
|
885
885
|
webRTCClass.close()
|
|
886
886
|
|
|
887
|
-
|
|
887
|
+
let tmpReconnectOnClose = reconnectOnClose;
|
|
888
|
+
reconnectOnClose = false;
|
|
889
|
+
retryStep.set(0);
|
|
890
|
+
|
|
891
|
+
if(protocol === "websocket")
|
|
892
|
+
socket.connect();
|
|
893
|
+
else if(protocol == "webrtc")
|
|
894
|
+
webRTCClass.connect()
|
|
895
|
+
|
|
896
|
+
setTimeout(function () {
|
|
888
897
|
// retryStep = 4;
|
|
889
|
-
retryStep.set(
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
898
|
+
retryStep.set(0);
|
|
899
|
+
reconnectOnClose = tmpReconnectOnClose;
|
|
900
|
+
|
|
901
|
+
if(socketState != socketStateType.OPEN){
|
|
902
|
+
if(protocol === "websocket")
|
|
903
|
+
socket.connect();
|
|
904
|
+
else if(protocol == "webrtc")
|
|
905
|
+
webRTCClass.connect()
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
// if(protocol === "websocket")
|
|
909
|
+
// socket.connect();
|
|
910
|
+
// else if(protocol == "webrtc")
|
|
911
|
+
// webRTCClass.connect()
|
|
912
|
+
}, 4000);
|
|
895
913
|
};
|
|
896
914
|
|
|
897
915
|
this.generateUUID = Utility.generateUUID;
|
package/src/network/webrtc.js
CHANGED
|
@@ -282,7 +282,11 @@ let handshakingFunctions = {
|
|
|
282
282
|
method: "POST",
|
|
283
283
|
body: JSON.stringify({
|
|
284
284
|
offer: offer
|
|
285
|
-
})
|
|
285
|
+
}),
|
|
286
|
+
headers: {
|
|
287
|
+
"Content-Type": "application/json",
|
|
288
|
+
// 'Content-Type': 'application/x-www-form-urlencoded',
|
|
289
|
+
},
|
|
286
290
|
})
|
|
287
291
|
.then(function (response) {
|
|
288
292
|
if(response.ok)
|
|
@@ -315,7 +319,11 @@ let handshakingFunctions = {
|
|
|
315
319
|
return new Promise(promiseHandler);
|
|
316
320
|
function promiseHandler(resolve, reject) {
|
|
317
321
|
fetch(addIceCandidateEndPoint, {
|
|
318
|
-
method: "GET"
|
|
322
|
+
method: "GET",
|
|
323
|
+
headers: {
|
|
324
|
+
"Content-Type": "application/json",
|
|
325
|
+
// 'Content-Type': 'application/x-www-form-urlencoded',
|
|
326
|
+
},
|
|
319
327
|
})
|
|
320
328
|
.then(function (response) {
|
|
321
329
|
if(response.ok)
|
|
@@ -365,7 +373,11 @@ let handshakingFunctions = {
|
|
|
365
373
|
body: JSON.stringify({
|
|
366
374
|
"clientId": variables.clientId,
|
|
367
375
|
"candidate": candidate
|
|
368
|
-
})
|
|
376
|
+
}),
|
|
377
|
+
headers: {
|
|
378
|
+
"Content-Type": "application/json",
|
|
379
|
+
// 'Content-Type': 'application/x-www-form-urlencoded',
|
|
380
|
+
},
|
|
369
381
|
})
|
|
370
382
|
.then(function (response) {
|
|
371
383
|
if(response.ok)
|
|
@@ -416,11 +428,14 @@ function ping() {
|
|
|
416
428
|
});
|
|
417
429
|
}
|
|
418
430
|
function removeCallbacks(){
|
|
419
|
-
variables.peerConnection
|
|
420
|
-
|
|
421
|
-
variables.dataChannel
|
|
422
|
-
|
|
423
|
-
|
|
431
|
+
if(variables.peerConnection)
|
|
432
|
+
variables.peerConnection.onicecandidate = null;
|
|
433
|
+
if(variables.dataChannel) {
|
|
434
|
+
variables.dataChannel.onclose = null;
|
|
435
|
+
variables.dataChannel.onmessage = null;
|
|
436
|
+
variables.dataChannel.onerror = null;
|
|
437
|
+
variables.dataChannel.onopen = null;
|
|
438
|
+
}
|
|
424
439
|
}
|
|
425
440
|
|
|
426
441
|
function WebRTCClass({
|