constants.uts
932 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
export const WsCommand = {
GetLog: "getLog",
GetStorage: "getStorage",
Message: "message",
GetLogList: "getLogList",
RemoveLog: "removeLog",
RemoveRecord: "removeRecord",
StopPolling: "stopPolling",
StartPolling: "startPolling",
SetPollingInterval: "setPollingInterval",
Records: "records",
TempRecords: "tempRecords",
RemoveTempRecord: "removeTempRecord",
AddTempRecord: "addTempRecord",
AddRecord: "addRecord",
ExecuteSql: "executeSql",
LiveLog: "liveLog",
FileExplorer: "fileExplorer",
UploadFile: "uploadFile"
} as UTSJSONObject;
export const WsMessageType = {
Private: "private",
System: "system"
} as UTSJSONObject;
export function normalizeWsUrl(url: string): string {
if (url.startsWith("ws://") || url.startsWith("wss://")) {
return url;
}
if (url.startsWith("https://")) {
return `wss://${url.slice(8)}`;
}
if (url.startsWith("http://")) {
return `ws://${url.slice(7)}`;
}
return url;
}