File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ export interface SocketOptions {
1313}
1414
1515export class Protocol extends PersistentProtocol {
16+ private disposed : boolean = false ;
17+
1618 public constructor (
1719 secWebsocketKey : string ,
1820 socket : net . Socket ,
@@ -40,12 +42,21 @@ export class Protocol extends PersistentProtocol {
4042 ] . join ( "\r\n" ) + "\r\n\r\n" ) ;
4143 }
4244
45+ public sendDisconnect ( ) : void {
46+ if ( ! this . disposed ) {
47+ super . sendDisconnect ( ) ;
48+ }
49+ }
50+
4351 public dispose ( error ?: Error ) : void {
44- if ( error ) {
45- this . sendMessage ( { type : "error" , reason : error . message } ) ;
52+ if ( ! this . disposed ) {
53+ this . disposed = true ;
54+ if ( error ) {
55+ this . sendMessage ( { type : "error" , reason : error . message } ) ;
56+ }
57+ super . dispose ( ) ;
58+ this . getSocket ( ) . dispose ( ) ;
4659 }
47- super . dispose ( ) ;
48- this . getSocket ( ) . dispose ( ) ;
4960 }
5061
5162 /**
You can’t perform that action at this time.
0 commit comments