@@ -4,6 +4,8 @@ import { ClientProxy } from "../../common/proxy";
4
4
import { NetModuleProxy , NetServerProxy , NetSocketProxy } from "../../node/modules/net" ;
5
5
import { Duplex } from "./stream" ;
6
6
7
+ // tslint:disable completed-docs
8
+
7
9
export class Socket extends Duplex < NetSocketProxy > implements net . Socket {
8
10
private _connecting : boolean = false ;
9
11
private _destroyed : boolean = false ;
@@ -29,9 +31,8 @@ export class Socket extends Duplex<NetSocketProxy> implements net.Socket {
29
31
if ( callback ) {
30
32
this . on ( "connect" , callback as ( ) => void ) ;
31
33
}
32
- this . proxy . connect ( options , host ) ;
33
34
34
- return this ;
35
+ return this . catch ( this . proxy . connect ( options , host ) ) ;
35
36
}
36
37
37
38
// tslint:disable-next-line no-any
@@ -117,11 +118,11 @@ export class Socket extends Duplex<NetSocketProxy> implements net.Socket {
117
118
}
118
119
119
120
public unref ( ) : void {
120
- this . proxy . unref ( ) ;
121
+ this . catch ( this . proxy . unref ( ) ) ;
121
122
}
122
123
123
124
public ref ( ) : void {
124
- this . proxy . ref ( ) ;
125
+ this . catch ( this . proxy . ref ( ) ) ;
125
126
}
126
127
}
127
128
@@ -133,14 +134,14 @@ export class Server extends ClientProxy<NetServerProxy> implements net.Server {
133
134
public constructor ( proxyPromise : Promise < NetServerProxy > | NetServerProxy ) {
134
135
super ( proxyPromise ) ;
135
136
136
- this . proxy . onConnection ( ( socketProxy ) => {
137
+ this . catch ( this . proxy . onConnection ( ( socketProxy ) => {
137
138
const socket = new Socket ( socketProxy ) ;
138
139
const socketId = this . socketId ++ ;
139
140
this . sockets . set ( socketId , socket ) ;
140
- socket . on ( "error" , ( ) => this . sockets . delete ( socketId ) )
141
- socket . on ( "close" , ( ) => this . sockets . delete ( socketId ) )
141
+ socket . on ( "error" , ( ) => this . sockets . delete ( socketId ) ) ;
142
+ socket . on ( "close" , ( ) => this . sockets . delete ( socketId ) ) ;
142
143
this . emit ( "connection" , socket ) ;
143
- } ) ;
144
+ } ) ) ;
144
145
145
146
this . on ( "listening" , ( ) => this . _listening = true ) ;
146
147
this . on ( "error" , ( ) => this . _listening = false ) ;
@@ -160,9 +161,7 @@ export class Server extends ClientProxy<NetServerProxy> implements net.Server {
160
161
this . on ( "listening" , callback as ( ) => void ) ;
161
162
}
162
163
163
- this . proxy . listen ( handle , hostname , backlog ) ;
164
-
165
- return this ;
164
+ return this . catch ( this . proxy . listen ( handle , hostname , backlog ) ) ;
166
165
}
167
166
168
167
public get connections ( ) : number {
@@ -186,21 +185,16 @@ export class Server extends ClientProxy<NetServerProxy> implements net.Server {
186
185
if ( callback ) {
187
186
this . on ( "close" , callback ) ;
188
187
}
189
- this . proxy . close ( ) ;
190
188
191
- return this ;
189
+ return this . catch ( this . proxy . close ( ) ) ;
192
190
}
193
191
194
192
public ref ( ) : this {
195
- this . proxy . ref ( ) ;
196
-
197
- return this ;
193
+ return this . catch ( this . proxy . ref ( ) ) ;
198
194
}
199
195
200
196
public unref ( ) : this {
201
- this . proxy . unref ( ) ;
202
-
203
- return this ;
197
+ return this . catch ( this . proxy . unref ( ) ) ;
204
198
}
205
199
206
200
public getConnections ( cb : ( error : Error | null , count : number ) => void ) : void {
0 commit comments