mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-20 02:03:19 +00:00
Fix terminal WebSocket ready state checks
This commit is contained in:
parent
9cca6e3e87
commit
8bf8319042
1 changed files with 8 additions and 4 deletions
|
|
@ -681,7 +681,7 @@ export class ProcessTerminalSession {
|
||||||
}
|
}
|
||||||
|
|
||||||
close(): void {
|
close(): void {
|
||||||
if (this.socket.readyState === WebSocket.CONNECTING) {
|
if (this.socket.readyState === WS_READY_STATE_CONNECTING) {
|
||||||
this.socket.addEventListener(
|
this.socket.addEventListener(
|
||||||
"open",
|
"open",
|
||||||
() => {
|
() => {
|
||||||
|
|
@ -692,7 +692,7 @@ export class ProcessTerminalSession {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.socket.readyState === WebSocket.OPEN) {
|
if (this.socket.readyState === WS_READY_STATE_OPEN) {
|
||||||
if (!this.closeSignalSent) {
|
if (!this.closeSignalSent) {
|
||||||
this.closeSignalSent = true;
|
this.closeSignalSent = true;
|
||||||
this.sendFrame({ type: "close" });
|
this.sendFrame({ type: "close" });
|
||||||
|
|
@ -701,7 +701,7 @@ export class ProcessTerminalSession {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.socket.readyState !== WebSocket.CLOSED) {
|
if (this.socket.readyState !== WS_READY_STATE_CLOSED) {
|
||||||
this.socket.close();
|
this.socket.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -743,7 +743,7 @@ export class ProcessTerminalSession {
|
||||||
}
|
}
|
||||||
|
|
||||||
private sendFrame(frame: ProcessTerminalClientFrame): void {
|
private sendFrame(frame: ProcessTerminalClientFrame): void {
|
||||||
if (this.socket.readyState !== WebSocket.OPEN) {
|
if (this.socket.readyState !== WS_READY_STATE_OPEN) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -757,6 +757,10 @@ export class ProcessTerminalSession {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const WS_READY_STATE_CONNECTING = 0;
|
||||||
|
const WS_READY_STATE_OPEN = 1;
|
||||||
|
const WS_READY_STATE_CLOSED = 3;
|
||||||
|
|
||||||
export class SandboxAgent {
|
export class SandboxAgent {
|
||||||
private readonly baseUrl: string;
|
private readonly baseUrl: string;
|
||||||
private readonly token?: string;
|
private readonly token?: string;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue