mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-21 16:38:23 +01:00
more const crusade
This commit is contained in:
parent
ed43d7e0a8
commit
e6f60ff210
@ -295,7 +295,7 @@ function handleWSMessage(msg: any) {
|
||||
}
|
||||
|
||||
function initWS() {
|
||||
let windowId = globalStore.get(atoms.windowId);
|
||||
const windowId = globalStore.get(atoms.windowId);
|
||||
globalWS = new WSControl(getWSServerEndpoint(), globalStore, windowId, "", (msg) => {
|
||||
handleWSMessage(msg);
|
||||
});
|
||||
@ -344,7 +344,7 @@ async function fetchWaveFile(
|
||||
fileName: string,
|
||||
offset?: number
|
||||
): Promise<{ data: Uint8Array; fileInfo: WaveFile }> {
|
||||
let usp = new URLSearchParams();
|
||||
const usp = new URLSearchParams();
|
||||
usp.set("zoneid", zoneId);
|
||||
usp.set("name", fileName);
|
||||
if (offset != null) {
|
||||
@ -360,11 +360,11 @@ async function fetchWaveFile(
|
||||
if (resp.status == 204) {
|
||||
return { data: null, fileInfo: null };
|
||||
}
|
||||
let fileInfo64 = resp.headers.get("X-ZoneFileInfo");
|
||||
const fileInfo64 = resp.headers.get("X-ZoneFileInfo");
|
||||
if (fileInfo64 == null) {
|
||||
throw new Error(`missing zone file info for ${zoneId}:${fileName}`);
|
||||
}
|
||||
let fileInfo = JSON.parse(atob(fileInfo64));
|
||||
const fileInfo = JSON.parse(atob(fileInfo64));
|
||||
const data = await resp.arrayBuffer();
|
||||
return { data: new Uint8Array(data), fileInfo };
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ function wshServerRpcHelper_responsestream(
|
||||
if (opts?.noresponse) {
|
||||
throw new Error("noresponse not supported for responsestream calls");
|
||||
}
|
||||
let msg: RpcMessage = {
|
||||
const msg: RpcMessage = {
|
||||
command: command,
|
||||
data: data,
|
||||
reqid: uuidv4(),
|
||||
@ -128,7 +128,7 @@ function wshServerRpcHelper_responsestream(
|
||||
}
|
||||
|
||||
function wshServerRpcHelper_call(command: string, data: any, opts: WshRpcCommandOpts): Promise<any> {
|
||||
let msg: RpcMessage = {
|
||||
const msg: RpcMessage = {
|
||||
command: command,
|
||||
data: data,
|
||||
};
|
||||
|
@ -44,7 +44,7 @@ class WSControl {
|
||||
}
|
||||
|
||||
log(str: string) {
|
||||
let ts = Date.now();
|
||||
const ts = Date.now();
|
||||
this.wsLog.push("[" + ts + "] " + str);
|
||||
if (this.wsLog.length > 50) {
|
||||
this.wsLog.splice(0, this.wsLog.length - 50);
|
||||
@ -86,7 +86,7 @@ class WSControl {
|
||||
this.log("cannot connect, giving up");
|
||||
return;
|
||||
}
|
||||
let timeoutArr = [0, 0, 2, 5, 10, 10, 30, 60];
|
||||
const timeoutArr = [0, 0, 2, 5, 10, 10, 30, 60];
|
||||
let timeout = 60;
|
||||
if (this.reconnectTimes < timeoutArr.length) {
|
||||
timeout = timeoutArr[this.reconnectTimes];
|
||||
@ -131,7 +131,7 @@ class WSControl {
|
||||
if (this.msgQueue.length == 0) {
|
||||
return;
|
||||
}
|
||||
let msg = this.msgQueue.shift();
|
||||
const msg = this.msgQueue.shift();
|
||||
this.sendMessage(msg);
|
||||
setTimeout(() => {
|
||||
this.runMsgQueue();
|
||||
@ -178,7 +178,7 @@ class WSControl {
|
||||
if (!this.isOpen()) {
|
||||
return;
|
||||
}
|
||||
let msg = JSON.stringify(data);
|
||||
const msg = JSON.stringify(data);
|
||||
const byteSize = new Blob([msg]).size;
|
||||
if (byteSize > MaxWebSocketSendSize) {
|
||||
console.log("ws message too large", byteSize, data.wscommand, msg.substring(0, 100));
|
||||
|
@ -66,7 +66,7 @@ async function* rpcResponseGenerator(
|
||||
}
|
||||
|
||||
function sendRpcCommand(msg: RpcMessage): AsyncGenerator<RpcMessage, void, boolean> {
|
||||
let wsMsg: WSRpcCommand = { wscommand: "rpc", message: msg };
|
||||
const wsMsg: WSRpcCommand = { wscommand: "rpc", message: msg };
|
||||
globalWS.pushMessage(wsMsg);
|
||||
if (msg.reqid == null) {
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user