remoterigs-raspberrypi 0.1.2 → 0.1.3
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/common/signalr.js +3 -3
- package/src/common/webrtc-streamer-wrapper.js +9 -9
- package/src/component/component.js +1 -1
- package/src/models/models.js +2 -2
- package/src/src/common/code.js +62 -0
- package/src/src/common/debug.js +77 -0
- package/src/src/common/signalr.js +189 -0
- package/src/src/common/webrtc-streamer-wrapper.js +483 -0
- package/src/src/component/component.js +358 -0
- package/src/src/component/input/input.js +26 -0
- package/src/src/component/pin/pin.js +92 -0
- package/src/src/component/property/property.js +32 -0
- package/src/src/component/status/status-number.js +7 -0
- package/src/src/component/status/status-state.js +27 -0
- package/src/src/component/status/status.js +41 -0
- package/src/src/models/models.js +1045 -0
- package/src/src/rig.js +65 -0
- package/src/src/server.js +87 -0
package/package.json
CHANGED
package/src/common/signalr.js
CHANGED
|
@@ -33,7 +33,7 @@ export default class SignalR {
|
|
|
33
33
|
if (Server.rig.rig.id !== webRTCMessage.rigId) {
|
|
34
34
|
Debug.Error(SignalR.GetName(), "incoming web-rtc-message error Server.rig.rig.id (" + Server.rig.rig.id + ") !== message.rigId (" + webRTCMessage.rigId + ")");
|
|
35
35
|
}
|
|
36
|
-
Debug.Log(LogSettingType.SignalR, undefined, SignalR.GetName(), "incoming web-rtc-message rigId:" + webRTCMessage.rigId + " componentId:" + webRTCMessage.componentId + "
|
|
36
|
+
Debug.Log(LogSettingType.SignalR, undefined, SignalR.GetName(), "incoming web-rtc-message rigId:" + webRTCMessage.rigId + " componentId:" + webRTCMessage.componentId + " userName: " + webRTCMessage.userName + " rigOwnerUsername: " + webRTCMessage.rigOwnerUsername);
|
|
37
37
|
Server.rig.PutWebRTCMessage(webRTCMessage);
|
|
38
38
|
}
|
|
39
39
|
else {
|
|
@@ -157,10 +157,10 @@ export default class SignalR {
|
|
|
157
157
|
}
|
|
158
158
|
static SendWebRTCMessage(message) {
|
|
159
159
|
if (SignalR.hubConnection != null && SignalR.IsConnected()) {
|
|
160
|
-
Debug.Log(LogSettingType.SignalR, undefined, SignalR.GetName(), "outgoing SendWebRTCMessage rigId: " + message.rigId + " componentId:" + message.componentId + "
|
|
160
|
+
Debug.Log(LogSettingType.SignalR, undefined, SignalR.GetName(), "outgoing SendWebRTCMessage rigId: " + message.rigId + " componentId:" + message.componentId + " userName: " + message.userName + " rigOwnerUsername: " + message.rigOwnerUsername);
|
|
161
161
|
SignalR.hubConnection.invoke("SendWebRTCMessage", message)
|
|
162
162
|
.then(() => {
|
|
163
|
-
Debug.Log(LogSettingType.SignalR, undefined, SignalR.GetName(), "outgoing SendWebRTCMessage success rigId: " + message.rigId + " componentId:" + message.componentId + "
|
|
163
|
+
Debug.Log(LogSettingType.SignalR, undefined, SignalR.GetName(), "outgoing SendWebRTCMessage success rigId: " + message.rigId + " componentId:" + message.componentId + " userName: " + message.userName + " rigOwnerUsername: " + message.rigOwnerUsername);
|
|
164
164
|
})
|
|
165
165
|
.catch((err) => {
|
|
166
166
|
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 userName: " + message.userName + " 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 userName: " + message.userName + " messageType: " + message.messageType);
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
async StartWebRTCStreamer() {
|
|
@@ -189,7 +189,7 @@ export default class WebRTCStreamerWrapper {
|
|
|
189
189
|
webrtcMessage.rigId = message.rigId;
|
|
190
190
|
webrtcMessage.webRTCConnectionType = message.webRTCConnectionType;
|
|
191
191
|
webrtcMessage.sessionId = message.sessionId;
|
|
192
|
-
webrtcMessage.
|
|
192
|
+
webrtcMessage.userName = message.userName;
|
|
193
193
|
webrtcMessage.rigOwnerUsername = message.rigOwnerUsername;
|
|
194
194
|
webrtcMessage.messageType = 'getIceServersResponse';
|
|
195
195
|
webrtcMessage.message = JSON.stringify(response.data);
|
|
@@ -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.
|
|
252
|
+
webrtcMessage.userName = message.userName;
|
|
253
253
|
webrtcMessage.rigOwnerUsername = message.rigOwnerUsername;
|
|
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.userName, message.rigOwnerUsername, message.webRTCConnectionType);
|
|
259
259
|
}
|
|
260
260
|
else {
|
|
261
261
|
this.Error("devicePath is empty");
|
|
@@ -324,7 +324,7 @@ export default class WebRTCStreamerWrapper {
|
|
|
324
324
|
webrtcMessage.rigId = message.rigId;
|
|
325
325
|
webrtcMessage.webRTCConnectionType = message.webRTCConnectionType;
|
|
326
326
|
webrtcMessage.sessionId = message.sessionId;
|
|
327
|
-
webrtcMessage.
|
|
327
|
+
webrtcMessage.userName = message.userName;
|
|
328
328
|
webrtcMessage.rigOwnerUsername = message.rigOwnerUsername;
|
|
329
329
|
webrtcMessage.messageType = 'receiveOffer';
|
|
330
330
|
//webrtcMessage.message = JSON.stringify(response.data);
|
|
@@ -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.userName, message.rigOwnerUsername, 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, userName, rigOwnerUsername, webRTCConnectionType) {
|
|
369
369
|
// Stop eventuele bestaande polling voor deze peer
|
|
370
370
|
this.StopIceCandidatePolling(peerId);
|
|
371
371
|
// Initialiseer candidate tracking voor deze peer
|
|
@@ -401,7 +401,7 @@ export default class WebRTCStreamerWrapper {
|
|
|
401
401
|
webrtcMessage.rigId = rigId;
|
|
402
402
|
webrtcMessage.sessionId = peerId;
|
|
403
403
|
webrtcMessage.webRTCConnectionType = webRTCConnectionType;
|
|
404
|
-
webrtcMessage.
|
|
404
|
+
webrtcMessage.userName = userName;
|
|
405
405
|
webrtcMessage.rigOwnerUsername = rigOwnerUsername;
|
|
406
406
|
webrtcMessage.messageType = 'onReceiveCandidate';
|
|
407
407
|
webrtcMessage.message = JSON.stringify(candidate);
|
|
@@ -193,7 +193,7 @@ export default class Component {
|
|
|
193
193
|
}
|
|
194
194
|
PutWebRTCMessage(message) {
|
|
195
195
|
if (this.component.id == message.componentId) {
|
|
196
|
-
this.Log("PutWebRTCMessage
|
|
196
|
+
this.Log("PutWebRTCMessage userName: " + message.userName + " rigOwnerUsername: " + message.rigOwnerUsername);
|
|
197
197
|
if (this.streamer != null) {
|
|
198
198
|
this.streamer.PutWebRTCMessage(message);
|
|
199
199
|
}
|
package/src/models/models.js
CHANGED
|
@@ -224,7 +224,7 @@ export class WebRTCMessage {
|
|
|
224
224
|
this.componentId = _data["componentId"];
|
|
225
225
|
this.webRTCConnectionType = _data["webRTCConnectionType"];
|
|
226
226
|
this.sessionId = _data["sessionId"];
|
|
227
|
-
this.
|
|
227
|
+
this.userName = _data["userName"];
|
|
228
228
|
this.messageType = _data["messageType"];
|
|
229
229
|
this.message = _data["message"];
|
|
230
230
|
}
|
|
@@ -242,7 +242,7 @@ export class WebRTCMessage {
|
|
|
242
242
|
data["componentId"] = this.componentId;
|
|
243
243
|
data["webRTCConnectionType"] = this.webRTCConnectionType;
|
|
244
244
|
data["sessionId"] = this.sessionId;
|
|
245
|
-
data["
|
|
245
|
+
data["userName"] = this.userName;
|
|
246
246
|
data["messageType"] = this.messageType;
|
|
247
247
|
data["message"] = this.message;
|
|
248
248
|
return data;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import vm from "vm";
|
|
2
|
+
import SignalR from "./signalr.js";
|
|
3
|
+
export default class Code {
|
|
4
|
+
static GetComponentContext(component) {
|
|
5
|
+
return {
|
|
6
|
+
SetCallback: component.SetCallback,
|
|
7
|
+
SetStatus: component.SetStatus,
|
|
8
|
+
SetStatusState: component.SetStatusState,
|
|
9
|
+
GetStatus: component.GetStatus,
|
|
10
|
+
GetStatusState: component.GetStatusState,
|
|
11
|
+
GetName: component.GetName,
|
|
12
|
+
GetStorageName: component.GetStorageName,
|
|
13
|
+
GetChild: component.GetChild,
|
|
14
|
+
Log: component.Log,
|
|
15
|
+
LogAlways: component.LogAlways,
|
|
16
|
+
Error: component.Error,
|
|
17
|
+
GetProperty: component.GetProperty,
|
|
18
|
+
GetPropertyNumber: component.GetPropertyNumber,
|
|
19
|
+
SetTimeOut: component.SetTimeOut,
|
|
20
|
+
ResetTimeOut: component.ResetTimeOut,
|
|
21
|
+
IsEventInput: component.IsEventInput,
|
|
22
|
+
child: component.child,
|
|
23
|
+
property: component.property,
|
|
24
|
+
input: component.input,
|
|
25
|
+
component: component.component,
|
|
26
|
+
pin: component.pin,
|
|
27
|
+
status: component.status,
|
|
28
|
+
boolean: component.boolean,
|
|
29
|
+
number: component.number,
|
|
30
|
+
string: component.string,
|
|
31
|
+
timeout: component.timeout,
|
|
32
|
+
streamer: component.streamer,
|
|
33
|
+
callback: component.callback
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/* (code: string, sandboxVars: SandboxVars): any {*/
|
|
37
|
+
/**
|
|
38
|
+
* Voert dynamische code uit in een veilige VM-sandbox.
|
|
39
|
+
* Geeft nette foutmeldingen met regelnummers.
|
|
40
|
+
*
|
|
41
|
+
* @param code - De code die moet worden uitgevoerd.
|
|
42
|
+
* @param contextVars - Variabelen die zichtbaar moeten zijn in de sandbox.
|
|
43
|
+
*/
|
|
44
|
+
static runSandboxed(code, contextVars = {}) {
|
|
45
|
+
const sandbox = {
|
|
46
|
+
SignalR: SignalR,
|
|
47
|
+
console,
|
|
48
|
+
...contextVars,
|
|
49
|
+
};
|
|
50
|
+
const context = vm.createContext(sandbox);
|
|
51
|
+
try {
|
|
52
|
+
return vm.runInContext(code, context, {
|
|
53
|
+
filename: "dynamic.js",
|
|
54
|
+
displayErrors: true,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
throw err; // laat native stacktrace intact
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=code.js.map
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { LogModel, LogSettingType, StatusModel, StatusType } from '../models/models.js';
|
|
2
|
+
import Server from "../server.js";
|
|
3
|
+
import SignalR from "./signalr.js";
|
|
4
|
+
export default class Debug {
|
|
5
|
+
// Timings
|
|
6
|
+
static { this.watchdogtimer = 1000; }
|
|
7
|
+
static { this.pwmdelay = 100; }
|
|
8
|
+
static { this.pwmstart = 120; }
|
|
9
|
+
static { this.pwm_frequency = 800; }
|
|
10
|
+
static { this.pwm_dutycycle_max = 1000000; }
|
|
11
|
+
static { this.time_to_full_speed_ms = 10000; }
|
|
12
|
+
static { this.commandtimer = 500; }
|
|
13
|
+
static SetErrorCallback(callback_param) {
|
|
14
|
+
Debug.error_callback = callback_param;
|
|
15
|
+
}
|
|
16
|
+
static Log(pVehicleSettingType, id, name, message) {
|
|
17
|
+
if (Debug.GetLogSetting(pVehicleSettingType, id)) {
|
|
18
|
+
Debug.LogAlways(name, message, true);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
static LogAlways(name, message, signalr) {
|
|
22
|
+
var date = new Date();
|
|
23
|
+
if (signalr) {
|
|
24
|
+
var logModel = new LogModel();
|
|
25
|
+
logModel.dateTime = date;
|
|
26
|
+
logModel.name = name;
|
|
27
|
+
logModel.message = message;
|
|
28
|
+
Debug.SendLogModel(logModel);
|
|
29
|
+
}
|
|
30
|
+
console.log(date.toLocaleTimeString() + " / " + name + " / " + message);
|
|
31
|
+
}
|
|
32
|
+
static Error(name, message) {
|
|
33
|
+
var date = new Date();
|
|
34
|
+
var logModel = new LogModel();
|
|
35
|
+
logModel.dateTime = date;
|
|
36
|
+
logModel.name = name;
|
|
37
|
+
logModel.message = message;
|
|
38
|
+
Debug.SendLogModel(logModel);
|
|
39
|
+
console.error(date.toLocaleTimeString() + " / " + name + " / " + message);
|
|
40
|
+
Debug.error_callback();
|
|
41
|
+
}
|
|
42
|
+
static SendLogModel(logModel) {
|
|
43
|
+
if (Server.rig != null) {
|
|
44
|
+
var tStatusModel = new StatusModel();
|
|
45
|
+
tStatusModel.type = StatusType.RigLog;
|
|
46
|
+
tStatusModel.value = logModel;
|
|
47
|
+
SignalR.UpdateStatus(tStatusModel);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
static GetLogSetting(pLogSettingType, id) {
|
|
51
|
+
if (Server.rig != null) {
|
|
52
|
+
for (var i = 0; i < Server.rig.rig.logSettings.length; i++) {
|
|
53
|
+
if (Server.rig.rig.logSettings[i].logSettingType == pLogSettingType &&
|
|
54
|
+
Server.rig.rig.logSettings[i].parameter1 == id) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
static GetStringValue(logSettingType) {
|
|
62
|
+
switch (logSettingType) {
|
|
63
|
+
case LogSettingType.BLESensor:
|
|
64
|
+
return "BLESensor";
|
|
65
|
+
case LogSettingType.Commands:
|
|
66
|
+
return "Commands";
|
|
67
|
+
case LogSettingType.KeyEvents:
|
|
68
|
+
return "KeyEvents";
|
|
69
|
+
case LogSettingType.SignalR:
|
|
70
|
+
return "SignalR";
|
|
71
|
+
case LogSettingType.Component:
|
|
72
|
+
return "Component";
|
|
73
|
+
}
|
|
74
|
+
return "";
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=debug.js.map
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { exec } from "child_process";
|
|
2
|
+
import * as signalR from '@microsoft/signalr';
|
|
3
|
+
import Server from './../server.js';
|
|
4
|
+
import Debug from './debug.js';
|
|
5
|
+
import Rig from '../rig.js';
|
|
6
|
+
import { LogSettingType, CommandType, StatusType } from '../models/models.js';
|
|
7
|
+
export default class SignalR {
|
|
8
|
+
static { this.hubConnection = null; }
|
|
9
|
+
static { this.reconnectTimer = null; }
|
|
10
|
+
static { this.lastUniqueCode = null; }
|
|
11
|
+
static { this.intentionalStop = false; }
|
|
12
|
+
static GetName() {
|
|
13
|
+
return "SignalR";
|
|
14
|
+
}
|
|
15
|
+
static StartConnection(uniquecode) {
|
|
16
|
+
SignalR.lastUniqueCode = uniquecode;
|
|
17
|
+
SignalR.intentionalStop = false;
|
|
18
|
+
Debug.LogAlways(SignalR.GetName(), "initiating hub connection... url: '" + Server.signalr + "'", false);
|
|
19
|
+
SignalR.hubConnection = new signalR.HubConnectionBuilder()
|
|
20
|
+
.withUrl(Server.signalr)
|
|
21
|
+
.withAutomaticReconnect()
|
|
22
|
+
.build();
|
|
23
|
+
SignalR.hubConnection.on('keyevent', (keyEventClientModel) => {
|
|
24
|
+
if (Server.rig != null) {
|
|
25
|
+
Server.rig.ProcessKeyEvent(keyEventClientModel);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
Debug.LogAlways(SignalR.GetName(), "no rig to process keyevent", true);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
SignalR.hubConnection.on("web-rtc-message", async (webRTCMessage) => {
|
|
32
|
+
if (Server.rig != null) {
|
|
33
|
+
if (Server.rig.rig.id !== webRTCMessage.rigId) {
|
|
34
|
+
Debug.Error(SignalR.GetName(), "incoming web-rtc-message error Server.rig.rig.id (" + Server.rig.rig.id + ") !== message.rigId (" + webRTCMessage.rigId + ")");
|
|
35
|
+
}
|
|
36
|
+
Debug.Log(LogSettingType.SignalR, undefined, SignalR.GetName(), "incoming web-rtc-message rigId:" + webRTCMessage.rigId + " componentId:" + webRTCMessage.componentId + " userName: " + webRTCMessage.userName + " rigOwnerUsername: " + webRTCMessage.rigOwnerUsername);
|
|
37
|
+
Server.rig.PutWebRTCMessage(webRTCMessage);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
Debug.LogAlways(SignalR.GetName(), "no rig to process webrtc message", true);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
SignalR.hubConnection.on("send-command", async (commandMessage) => {
|
|
44
|
+
Debug.Log(LogSettingType.SignalR, undefined, SignalR.GetName(), "incoming message: " + JSON.stringify(commandMessage));
|
|
45
|
+
switch (commandMessage.type) {
|
|
46
|
+
case CommandType.RigReloadRigModel:
|
|
47
|
+
SignalR.SignIn(uniquecode);
|
|
48
|
+
break;
|
|
49
|
+
case CommandType.RigShutdown:
|
|
50
|
+
Debug.LogAlways("Raspberry Pi", "SHUTTING DOWN!", true);
|
|
51
|
+
exec("shutdown now");
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
SignalR.hubConnection.onreconnecting((error) => {
|
|
56
|
+
Debug.LogAlways(SignalR.GetName(), "hub connection lost, attempting to reconnect..." + (error ? (" reason: " + error) : ""), true);
|
|
57
|
+
});
|
|
58
|
+
SignalR.hubConnection.onreconnected(() => {
|
|
59
|
+
Debug.LogAlways(SignalR.GetName(), "hub connection reconnected, re-signing in...", true);
|
|
60
|
+
SignalR.SignIn(uniquecode);
|
|
61
|
+
});
|
|
62
|
+
SignalR.hubConnection.onclose((error) => {
|
|
63
|
+
Debug.LogAlways(SignalR.GetName(), "hub connection closed" + (error ? (": " + error) : ""), true);
|
|
64
|
+
SignalR.ScheduleReconnect();
|
|
65
|
+
});
|
|
66
|
+
SignalR.hubConnection
|
|
67
|
+
.start()
|
|
68
|
+
.then(() => {
|
|
69
|
+
Debug.LogAlways(SignalR.GetName(), 'hub connection established', false);
|
|
70
|
+
SignalR.SignIn(uniquecode);
|
|
71
|
+
})
|
|
72
|
+
.catch((err) => {
|
|
73
|
+
Debug.Error(SignalR.GetName(), err);
|
|
74
|
+
SignalR.ScheduleReconnect();
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
static ScheduleReconnect() {
|
|
78
|
+
if (SignalR.intentionalStop) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (SignalR.reconnectTimer != null) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
Debug.LogAlways(SignalR.GetName(), "scheduling reconnect attempt in 30s...", true);
|
|
85
|
+
SignalR.reconnectTimer = setTimeout(() => {
|
|
86
|
+
SignalR.reconnectTimer = null;
|
|
87
|
+
if (SignalR.lastUniqueCode != null && !SignalR.intentionalStop) {
|
|
88
|
+
Debug.LogAlways(SignalR.GetName(), "attempting reconnect now...", true);
|
|
89
|
+
SignalR.StartConnection(SignalR.lastUniqueCode);
|
|
90
|
+
}
|
|
91
|
+
}, 30000);
|
|
92
|
+
}
|
|
93
|
+
static StopConnection() {
|
|
94
|
+
Debug.Log(LogSettingType.SignalR, undefined, SignalR.GetName(), "stopping hub connection...");
|
|
95
|
+
SignalR.intentionalStop = true;
|
|
96
|
+
if (SignalR.reconnectTimer != null) {
|
|
97
|
+
clearTimeout(SignalR.reconnectTimer);
|
|
98
|
+
SignalR.reconnectTimer = null;
|
|
99
|
+
}
|
|
100
|
+
if (SignalR.hubConnection) {
|
|
101
|
+
SignalR.hubConnection.stop()
|
|
102
|
+
.then(() => {
|
|
103
|
+
Debug.Log(LogSettingType.SignalR, undefined, SignalR.GetName(), 'hub connection stopped');
|
|
104
|
+
})
|
|
105
|
+
.catch((err) => {
|
|
106
|
+
Debug.Error(SignalR.GetName(), err);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
static IsConnected() {
|
|
111
|
+
return SignalR.hubConnection != null && SignalR.hubConnection.state === signalR.HubConnectionState.Connected;
|
|
112
|
+
}
|
|
113
|
+
static SignIn(uniquecode) {
|
|
114
|
+
if (SignalR.hubConnection != null && SignalR.IsConnected()) {
|
|
115
|
+
SignalR.hubConnection.invoke('SignIn', uniquecode)
|
|
116
|
+
.then((rigClientViewModel) => {
|
|
117
|
+
if (rigClientViewModel.rigModelViewModel == undefined) {
|
|
118
|
+
Debug.LogAlways(SignalR.GetName(), "SignIn failed!! GUID: " + uniquecode, true);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
Debug.LogAlways(SignalR.GetName(), "SignIn successful", true);
|
|
122
|
+
Server.rig = new Rig(rigClientViewModel);
|
|
123
|
+
Server.rig.CreateComponents();
|
|
124
|
+
Debug.LogAlways(SignalR.GetName(), "Rig components loaded", true);
|
|
125
|
+
Server.rig.Init();
|
|
126
|
+
Debug.LogAlways(SignalR.GetName(), "Rig 'Init' functions executed", true);
|
|
127
|
+
Server.rig.SendCurrent();
|
|
128
|
+
Debug.LogAlways(SignalR.GetName(), "Rig current status send", true);
|
|
129
|
+
}
|
|
130
|
+
})
|
|
131
|
+
.catch((err) => {
|
|
132
|
+
Debug.Error(SignalR.GetName(), err);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
Debug.Error(SignalR.GetName(), "outgoing SignIn: no hub connection");
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
static UpdateStatus(pStatusModel) {
|
|
140
|
+
if (SignalR.hubConnection != null && SignalR.IsConnected()) {
|
|
141
|
+
if (pStatusModel.type != StatusType.RigLog) {
|
|
142
|
+
Debug.Log(LogSettingType.SignalR, undefined, SignalR.GetName(), "outgoing UpdateStatus type: " + pStatusModel.type);
|
|
143
|
+
}
|
|
144
|
+
SignalR.hubConnection.invoke('UpdateStatus', pStatusModel)
|
|
145
|
+
.then(() => {
|
|
146
|
+
if (pStatusModel.type != StatusType.RigLog) {
|
|
147
|
+
Debug.Log(LogSettingType.SignalR, undefined, SignalR.GetName(), "outgoing UpdateStatus type: " + pStatusModel.type);
|
|
148
|
+
}
|
|
149
|
+
})
|
|
150
|
+
.catch((err) => {
|
|
151
|
+
Debug.Error(SignalR.GetName(), "outgoing UpdateStatus error: " + err);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
Debug.Error(SignalR.GetName(), "outgoing UpdateStatus: no hub connection");
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
static SendWebRTCMessage(message) {
|
|
159
|
+
if (SignalR.hubConnection != null && SignalR.IsConnected()) {
|
|
160
|
+
Debug.Log(LogSettingType.SignalR, undefined, SignalR.GetName(), "outgoing SendWebRTCMessage rigId: " + message.rigId + " componentId:" + message.componentId + " userName: " + message.userName + " rigOwnerUsername: " + message.rigOwnerUsername);
|
|
161
|
+
SignalR.hubConnection.invoke("SendWebRTCMessage", message)
|
|
162
|
+
.then(() => {
|
|
163
|
+
Debug.Log(LogSettingType.SignalR, undefined, SignalR.GetName(), "outgoing SendWebRTCMessage success rigId: " + message.rigId + " componentId:" + message.componentId + " userName: " + message.userName + " rigOwnerUsername: " + message.rigOwnerUsername);
|
|
164
|
+
})
|
|
165
|
+
.catch((err) => {
|
|
166
|
+
Debug.Error(SignalR.GetName(), "outgoing SendWebRTCMessage error: " + err);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
Debug.Error(SignalR.GetName(), "SendWebRTCMessage: no hub connection");
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
static AddHighScorePoints(message) {
|
|
174
|
+
if (SignalR.hubConnection != null && SignalR.IsConnected()) {
|
|
175
|
+
Debug.Log(LogSettingType.SignalR, undefined, SignalR.GetName(), "outgoing AddHighScorePoints: " + JSON.stringify(message));
|
|
176
|
+
SignalR.hubConnection.invoke("AddHighScorePoints", message)
|
|
177
|
+
.then(() => {
|
|
178
|
+
Debug.Log(LogSettingType.SignalR, undefined, SignalR.GetName(), "outgoing AddHighScorePoints success: " + JSON.stringify(message));
|
|
179
|
+
})
|
|
180
|
+
.catch((err) => {
|
|
181
|
+
Debug.Error(SignalR.GetName(), "outgoing AddHighScorePoints error: " + err);
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
Debug.Error(SignalR.GetName(), "outgoing AddHighScorePoints: no hub connection");
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
//# sourceMappingURL=signalr.js.map
|