remoterigs-raspberrypi 0.1.10 → 0.1.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/package.json
CHANGED
package/src/common/signalr.js
CHANGED
|
@@ -9,12 +9,15 @@ export default class SignalR {
|
|
|
9
9
|
static { this.reconnectTimer = null; }
|
|
10
10
|
static { this.lastUniqueCode = null; }
|
|
11
11
|
static { this.intentionalStop = false; }
|
|
12
|
+
static { this.signInRetryTimer = null; }
|
|
13
|
+
static { this.signInAttempts = 0; }
|
|
12
14
|
static GetName() {
|
|
13
15
|
return "SignalR";
|
|
14
16
|
}
|
|
15
17
|
static StartConnection(uniquecode) {
|
|
16
18
|
SignalR.lastUniqueCode = uniquecode;
|
|
17
19
|
SignalR.intentionalStop = false;
|
|
20
|
+
SignalR.CancelSignInRetry();
|
|
18
21
|
Debug.LogAlways(SignalR.GetName(), "initiating hub connection... url: '" + Server.signalr + "'", false);
|
|
19
22
|
SignalR.hubConnection = new signalR.HubConnectionBuilder()
|
|
20
23
|
.withUrl(Server.signalr)
|
|
@@ -33,7 +36,7 @@ export default class SignalR {
|
|
|
33
36
|
if (Server.rig.rig.id !== webRTCMessage.rigId) {
|
|
34
37
|
Debug.Error(SignalR.GetName(), "incoming web-rtc-message error Server.rig.rig.id (" + Server.rig.rig.id + ") !== message.rigId (" + webRTCMessage.rigId + ")");
|
|
35
38
|
}
|
|
36
|
-
Debug.Log(LogSettingType.SignalR, undefined, SignalR.GetName(), "incoming web-rtc-message rigId:" + webRTCMessage.rigId + " componentId:" + webRTCMessage.componentId + "
|
|
39
|
+
Debug.Log(LogSettingType.SignalR, undefined, SignalR.GetName(), "incoming web-rtc-message rigId:" + webRTCMessage.rigId + " componentId:" + webRTCMessage.componentId + " userId: " + webRTCMessage.userId + " rigOwnerUserId: " + webRTCMessage.rigOwnerUserId);
|
|
37
40
|
Server.rig.PutWebRTCMessage(webRTCMessage);
|
|
38
41
|
}
|
|
39
42
|
else {
|
|
@@ -61,6 +64,8 @@ export default class SignalR {
|
|
|
61
64
|
});
|
|
62
65
|
SignalR.hubConnection.onclose((error) => {
|
|
63
66
|
Debug.LogAlways(SignalR.GetName(), "hub connection closed" + (error ? (": " + error) : ""), true);
|
|
67
|
+
// a new connection signs in itself (StartConnection)
|
|
68
|
+
SignalR.CancelSignInRetry();
|
|
64
69
|
SignalR.ScheduleReconnect();
|
|
65
70
|
});
|
|
66
71
|
SignalR.hubConnection
|
|
@@ -76,7 +81,6 @@ export default class SignalR {
|
|
|
76
81
|
}
|
|
77
82
|
static ScheduleReconnect() {
|
|
78
83
|
if (SignalR.intentionalStop) {
|
|
79
|
-
1;
|
|
80
84
|
return;
|
|
81
85
|
}
|
|
82
86
|
if (SignalR.reconnectTimer != null) {
|
|
@@ -91,9 +95,35 @@ export default class SignalR {
|
|
|
91
95
|
}
|
|
92
96
|
}, 30000);
|
|
93
97
|
}
|
|
98
|
+
/// The server refuses a sign in while another connection is still signed in as this rig. After a network drop
|
|
99
|
+
/// that is our own old connection: the server only drops it after the SignalR timeout (30s). The server also
|
|
100
|
+
/// refuses (with the same empty answer) when there are too many sign in attempts from this IP address.
|
|
101
|
+
/// So keep trying: after 5s, 10s, 20s and then every 30s.
|
|
102
|
+
static ScheduleSignInRetry(uniquecode) {
|
|
103
|
+
if (SignalR.intentionalStop || SignalR.signInRetryTimer != null) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
SignalR.signInAttempts++;
|
|
107
|
+
const delay = Math.min(5000 * Math.pow(2, SignalR.signInAttempts - 1), 30000);
|
|
108
|
+
Debug.LogAlways(SignalR.GetName(), "retrying sign in in " + (delay / 1000) + "s (attempt " + SignalR.signInAttempts + ")...", true);
|
|
109
|
+
SignalR.signInRetryTimer = setTimeout(() => {
|
|
110
|
+
SignalR.signInRetryTimer = null;
|
|
111
|
+
if (!SignalR.intentionalStop) {
|
|
112
|
+
SignalR.SignIn(uniquecode);
|
|
113
|
+
}
|
|
114
|
+
}, delay);
|
|
115
|
+
}
|
|
116
|
+
static CancelSignInRetry() {
|
|
117
|
+
if (SignalR.signInRetryTimer != null) {
|
|
118
|
+
clearTimeout(SignalR.signInRetryTimer);
|
|
119
|
+
SignalR.signInRetryTimer = null;
|
|
120
|
+
}
|
|
121
|
+
SignalR.signInAttempts = 0;
|
|
122
|
+
}
|
|
94
123
|
static StopConnection() {
|
|
95
124
|
Debug.Log(LogSettingType.SignalR, undefined, SignalR.GetName(), "stopping hub connection...");
|
|
96
125
|
SignalR.intentionalStop = true;
|
|
126
|
+
SignalR.CancelSignInRetry();
|
|
97
127
|
if (SignalR.reconnectTimer != null) {
|
|
98
128
|
clearTimeout(SignalR.reconnectTimer);
|
|
99
129
|
SignalR.reconnectTimer = null;
|
|
@@ -116,9 +146,12 @@ export default class SignalR {
|
|
|
116
146
|
SignalR.hubConnection.invoke('SignIn', uniquecode)
|
|
117
147
|
.then((rigClientViewModel) => {
|
|
118
148
|
if (rigClientViewModel.rigModelViewModel == undefined) {
|
|
149
|
+
// unknown code, the rig is still signed in on another (old) connection, or too many attempts
|
|
119
150
|
Debug.LogAlways(SignalR.GetName(), "sign in to server failed! GUID: " + uniquecode, true);
|
|
151
|
+
SignalR.ScheduleSignInRetry(uniquecode);
|
|
120
152
|
}
|
|
121
153
|
else {
|
|
154
|
+
SignalR.CancelSignInRetry();
|
|
122
155
|
Debug.LogAlways(SignalR.GetName(), "sign in to server successful", true);
|
|
123
156
|
Debug.LogAlways(SignalR.GetName(), "rig #" + rigClientViewModel.id + " '" + rigClientViewModel.name + "'", true);
|
|
124
157
|
Debug.LogAlways(SignalR.GetName(), "rig model #" + rigClientViewModel.rigModelViewModel.id + " '" + rigClientViewModel.rigModelViewModel.name + "'", true);
|
|
@@ -157,10 +190,10 @@ export default class SignalR {
|
|
|
157
190
|
}
|
|
158
191
|
static SendWebRTCMessage(message) {
|
|
159
192
|
if (SignalR.hubConnection != null && SignalR.IsConnected()) {
|
|
160
|
-
Debug.Log(LogSettingType.SignalR, undefined, SignalR.GetName(), "outgoing SendWebRTCMessage rigId: " + message.rigId + " componentId:" + message.componentId + "
|
|
193
|
+
Debug.Log(LogSettingType.SignalR, undefined, SignalR.GetName(), "outgoing SendWebRTCMessage rigId: " + message.rigId + " componentId:" + message.componentId + " userId: " + message.userId + " rigOwnerUserId: " + message.rigOwnerUserId);
|
|
161
194
|
SignalR.hubConnection.invoke("SendWebRTCMessage", message)
|
|
162
195
|
.then(() => {
|
|
163
|
-
Debug.Log(LogSettingType.SignalR, undefined, SignalR.GetName(), "outgoing SendWebRTCMessage success rigId: " + message.rigId + " componentId:" + message.componentId + "
|
|
196
|
+
Debug.Log(LogSettingType.SignalR, undefined, SignalR.GetName(), "outgoing SendWebRTCMessage success rigId: " + message.rigId + " componentId:" + message.componentId + " userId: " + message.userId + " rigOwnerUserId: " + message.rigOwnerUserId);
|
|
164
197
|
})
|
|
165
198
|
.catch((err) => {
|
|
166
199
|
Debug.Error(SignalR.GetName(), "outgoing SendWebRTCMessage error: " + err);
|
|
@@ -47,7 +47,7 @@ export default class WebRTCStreamerWrapper {
|
|
|
47
47
|
}
|
|
48
48
|
async PutWebRTCMessage(message) {
|
|
49
49
|
if (this.streamerStarted) {
|
|
50
|
-
this.Log("PutWebRTCMessage
|
|
50
|
+
this.Log("PutWebRTCMessage userId: " + message.userId + " messageType: " + message.messageType);
|
|
51
51
|
if (message.messageType == "getIceServers") {
|
|
52
52
|
await this.GetIceServers(message);
|
|
53
53
|
}
|
|
@@ -88,7 +88,7 @@ export default class WebRTCStreamerWrapper {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
else {
|
|
91
|
-
this.Log("IGNORED! PutWebRTCMessage
|
|
91
|
+
this.Log("IGNORED! PutWebRTCMessage userId: " + message.userId + " messageType: " + message.messageType);
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
async StartWebRTCStreamer() {
|
|
@@ -189,8 +189,8 @@ export default class WebRTCStreamerWrapper {
|
|
|
189
189
|
webrtcMessage.rigId = message.rigId;
|
|
190
190
|
webrtcMessage.webRTCConnectionType = message.webRTCConnectionType;
|
|
191
191
|
webrtcMessage.sessionId = message.sessionId;
|
|
192
|
-
webrtcMessage.
|
|
193
|
-
webrtcMessage.
|
|
192
|
+
webrtcMessage.userId = message.userId;
|
|
193
|
+
webrtcMessage.rigOwnerUserId = message.rigOwnerUserId;
|
|
194
194
|
webrtcMessage.messageType = 'getIceServersResponse';
|
|
195
195
|
webrtcMessage.message = JSON.stringify(response.data);
|
|
196
196
|
SignalR.SendWebRTCMessage(webrtcMessage);
|
|
@@ -249,13 +249,13 @@ export default class WebRTCStreamerWrapper {
|
|
|
249
249
|
webrtcMessage.rigId = message.rigId;
|
|
250
250
|
webrtcMessage.sessionId = message.sessionId;
|
|
251
251
|
webrtcMessage.webRTCConnectionType = message.webRTCConnectionType;
|
|
252
|
-
webrtcMessage.
|
|
253
|
-
webrtcMessage.
|
|
252
|
+
webrtcMessage.userId = message.userId;
|
|
253
|
+
webrtcMessage.rigOwnerUserId = message.rigOwnerUserId;
|
|
254
254
|
webrtcMessage.messageType = 'onReceiveCall';
|
|
255
255
|
webrtcMessage.message = JSON.stringify(response.data);
|
|
256
256
|
SignalR.SendWebRTCMessage(webrtcMessage);
|
|
257
257
|
// Start polling voor ICE candidates van de server
|
|
258
|
-
this.StartIceCandidatePolling(message.sessionId, message.rigId, message.
|
|
258
|
+
this.StartIceCandidatePolling(message.sessionId, message.rigId, message.userId, message.rigOwnerUserId, message.webRTCConnectionType);
|
|
259
259
|
}
|
|
260
260
|
else {
|
|
261
261
|
this.Error("devicePath is empty");
|
|
@@ -324,8 +324,8 @@ export default class WebRTCStreamerWrapper {
|
|
|
324
324
|
webrtcMessage.rigId = message.rigId;
|
|
325
325
|
webrtcMessage.webRTCConnectionType = message.webRTCConnectionType;
|
|
326
326
|
webrtcMessage.sessionId = message.sessionId;
|
|
327
|
-
webrtcMessage.
|
|
328
|
-
webrtcMessage.
|
|
327
|
+
webrtcMessage.userId = message.userId;
|
|
328
|
+
webrtcMessage.rigOwnerUserId = message.rigOwnerUserId;
|
|
329
329
|
webrtcMessage.messageType = 'receiveOffer';
|
|
330
330
|
//webrtcMessage.message = JSON.stringify(response.data);
|
|
331
331
|
webrtcMessage.message = JSON.stringify({ ...response.data, sdp });
|
|
@@ -355,7 +355,7 @@ export default class WebRTCStreamerWrapper {
|
|
|
355
355
|
const response = await this.streamerClient.post(setAnswerUrl, tJSON);
|
|
356
356
|
this.Log("SetAnswer Response status: " + response.status);
|
|
357
357
|
this.Log("SetAnswer Response data:\\r\\n" + JSON.stringify(response.data?.sdp));
|
|
358
|
-
this.StartIceCandidatePolling(message.sessionId, message.rigId, message.
|
|
358
|
+
this.StartIceCandidatePolling(message.sessionId, message.rigId, message.userId, message.rigOwnerUserId, message.webRTCConnectionType);
|
|
359
359
|
}
|
|
360
360
|
catch (err) {
|
|
361
361
|
if (err.response) {
|
|
@@ -365,7 +365,7 @@ export default class WebRTCStreamerWrapper {
|
|
|
365
365
|
this.Error("SetAnswer Call error: " + err.message);
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
|
-
StartIceCandidatePolling(peerId, rigId,
|
|
368
|
+
StartIceCandidatePolling(peerId, rigId, userId, rigOwnerUserId, webRTCConnectionType) {
|
|
369
369
|
// Stop eventuele bestaande polling voor deze peer
|
|
370
370
|
this.StopIceCandidatePolling(peerId);
|
|
371
371
|
// Initialiseer candidate tracking voor deze peer
|
|
@@ -401,8 +401,8 @@ export default class WebRTCStreamerWrapper {
|
|
|
401
401
|
webrtcMessage.rigId = rigId;
|
|
402
402
|
webrtcMessage.sessionId = peerId;
|
|
403
403
|
webrtcMessage.webRTCConnectionType = webRTCConnectionType;
|
|
404
|
-
webrtcMessage.
|
|
405
|
-
webrtcMessage.
|
|
404
|
+
webrtcMessage.userId = userId;
|
|
405
|
+
webrtcMessage.rigOwnerUserId = rigOwnerUserId;
|
|
406
406
|
webrtcMessage.messageType = 'onReceiveCandidate';
|
|
407
407
|
webrtcMessage.message = JSON.stringify(candidate);
|
|
408
408
|
SignalR.SendWebRTCMessage(webrtcMessage);
|
|
@@ -194,7 +194,7 @@ export default class Component {
|
|
|
194
194
|
}
|
|
195
195
|
PutWebRTCMessage(message) {
|
|
196
196
|
if (this.component.id == message.componentId) {
|
|
197
|
-
this.Log("PutWebRTCMessage
|
|
197
|
+
this.Log("PutWebRTCMessage userId: " + message.userId + " rigOwnerUserId: " + message.rigOwnerUserId);
|
|
198
198
|
if (this.streamer != null) {
|
|
199
199
|
this.streamer.PutWebRTCMessage(message);
|
|
200
200
|
}
|
package/src/config.json.default
CHANGED
package/src/models/models.js
CHANGED
|
@@ -221,12 +221,12 @@ export class WebRTCMessage {
|
|
|
221
221
|
}
|
|
222
222
|
init(_data) {
|
|
223
223
|
if (_data) {
|
|
224
|
-
this.
|
|
224
|
+
this.rigOwnerUserId = _data["rigOwnerUserId"];
|
|
225
225
|
this.rigId = _data["rigId"];
|
|
226
226
|
this.componentId = _data["componentId"];
|
|
227
227
|
this.webRTCConnectionType = _data["webRTCConnectionType"];
|
|
228
228
|
this.sessionId = _data["sessionId"];
|
|
229
|
-
this.
|
|
229
|
+
this.userId = _data["userId"];
|
|
230
230
|
this.messageType = _data["messageType"];
|
|
231
231
|
this.message = _data["message"];
|
|
232
232
|
}
|
|
@@ -239,12 +239,12 @@ export class WebRTCMessage {
|
|
|
239
239
|
}
|
|
240
240
|
toJSON(data) {
|
|
241
241
|
data = typeof data === 'object' ? data : {};
|
|
242
|
-
data["
|
|
242
|
+
data["rigOwnerUserId"] = this.rigOwnerUserId;
|
|
243
243
|
data["rigId"] = this.rigId;
|
|
244
244
|
data["componentId"] = this.componentId;
|
|
245
245
|
data["webRTCConnectionType"] = this.webRTCConnectionType;
|
|
246
246
|
data["sessionId"] = this.sessionId;
|
|
247
|
-
data["
|
|
247
|
+
data["userId"] = this.userId;
|
|
248
248
|
data["messageType"] = this.messageType;
|
|
249
249
|
data["message"] = this.message;
|
|
250
250
|
return data;
|