Skip to content
This repository was archived by the owner on Jul 31, 2020. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/wire/Socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class InteractiveSocket extends EventEmitter {

private reconnectTimeout: NodeJS.Timer;
private options: ISocketOptions;
private state: SocketState;
private state: SocketState = SocketState.Idle;
private socket: any;
private queue: Set<Packet> = new Set<Packet>();

Expand Down Expand Up @@ -249,10 +249,12 @@ export class InteractiveSocket extends EventEmitter {
return;
}

this.state = SocketState.Closing;
this.socket.close(1000, 'Closed normally.');
this.queue.forEach(packet => packet.cancel());
this.queue.clear();
if (this.state !== SocketState.Idle) {
this.state = SocketState.Closing;
this.socket.close(1000, 'Closed normally.');
this.queue.forEach(packet => packet.cancel());
this.queue.clear();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably want to set the state to Closed if the conditional fails, for cleanliness. Not sure if anything actually looks at it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good ;)

}

/**
Expand Down