mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-15 20:03:11 +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 {
|
||||
if (this.socket.readyState === WebSocket.CONNECTING) {
|
||||
if (this.socket.readyState === WS_READY_STATE_CONNECTING) {
|
||||
this.socket.addEventListener(
|
||||
"open",
|
||||
() => {
|
||||
|
|
@ -692,7 +692,7 @@ export class ProcessTerminalSession {
|
|||
return;
|
||||
}
|
||||
|
||||
if (this.socket.readyState === WebSocket.OPEN) {
|
||||
if (this.socket.readyState === WS_READY_STATE_OPEN) {
|
||||
if (!this.closeSignalSent) {
|
||||
this.closeSignalSent = true;
|
||||
this.sendFrame({ type: "close" });
|
||||
|
|
@ -701,7 +701,7 @@ export class ProcessTerminalSession {
|
|||
return;
|
||||
}
|
||||
|
||||
if (this.socket.readyState !== WebSocket.CLOSED) {
|
||||
if (this.socket.readyState !== WS_READY_STATE_CLOSED) {
|
||||
this.socket.close();
|
||||
}
|
||||
}
|
||||
|
|
@ -743,7 +743,7 @@ export class ProcessTerminalSession {
|
|||
}
|
||||
|
||||
private sendFrame(frame: ProcessTerminalClientFrame): void {
|
||||
if (this.socket.readyState !== WebSocket.OPEN) {
|
||||
if (this.socket.readyState !== WS_READY_STATE_OPEN) {
|
||||
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 {
|
||||
private readonly baseUrl: string;
|
||||
private readonly token?: string;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue