5
5
* @property {number } [keepAliveInitialDelay]
6
6
* @property {boolean } [allowHalfOpen]
7
7
* @property {boolean } [pauseOnConnect]
8
- *
8
+ *
9
9
* @typedef {import('./TLSSocket').default } TLSSocket
10
10
*
11
11
* @typedef {object } ServerEvents
@@ -22,24 +22,22 @@ export default class Server extends EventEmitter<ServerEvents, any> {
22
22
* @param {ServerOptions | ((socket: Socket) => void) } [options] Server options or connection listener
23
23
* @param {(socket: Socket) => void } [connectionCallback] Automatically set as a listener for the `'connection'` event.
24
24
*/
25
- constructor ( options ?: ServerOptions | ( ( socket : Socket ) => void ) , connectionCallback ?: ( socket : Socket ) => void ) ;
26
-
25
+ constructor ( options ?: ServerOptions | ( ( socket : Socket ) => void ) | undefined , connectionCallback ?: ( ( socket : Socket ) => void ) | undefined ) ;
27
26
/** @protected @readonly */
28
27
protected readonly _id : number ;
29
28
/** @protected @readonly */
30
29
protected readonly _eventEmitter : import ( "react-native" ) . EventEmitter ;
31
30
/** @private @type {Set<Socket> } */
32
- private _connections : Set < Socket > ;
33
- /** @private */
34
- private _localAddress : string | undefined ;
31
+ private _connections ;
35
32
/** @private */
36
- private _localPort : number | undefined ;
33
+ private _localAddress ;
37
34
/** @private */
38
- private _localFamily : string | undefined ;
35
+ private _localPort ;
39
36
/** @private */
40
- private _serverOptions : ServerOptions ;
37
+ private _localFamily ;
38
+ /** @private @type {ServerOptions } */
39
+ private _serverOptions ;
41
40
listening : boolean ;
42
-
43
41
/**
44
42
* Start a server listening for connections.
45
43
*
@@ -50,15 +48,16 @@ export default class Server extends EventEmitter<ServerEvents, any> {
50
48
* `server.listen()` call or `server.close()` has been called. Otherwise, an `ERR_SERVER_ALREADY_LISTEN`
51
49
* error will be thrown.
52
50
*
53
- * @param {{ port: number; host?: string; reuseAddress?: boolean} | number } options
54
- * @param {string | (() => void) } [callback_or_host]
55
- * @param {() => void } [callback]
51
+ * @param {{ port: number; host?: string; reuseAddress?: boolean} | number } options Options or port
52
+ * @param {string | (() => void) } [callback_or_host] Callback or host string
53
+ * @param {() => void } [callback] Callback function
56
54
* @returns {Server }
57
55
*/
58
- listen ( options : { port : number ; host ?: string ; reuseAddress ?: boolean } | number ,
59
- callback_or_host ?: string | ( ( ) => void ) ,
60
- callback ?: ( ) => void ) : Server ;
61
-
56
+ listen ( options : {
57
+ port : number ;
58
+ host ?: string ;
59
+ reuseAddress ?: boolean ;
60
+ } | number , callback_or_host ?: string | ( ( ) => void ) | undefined , callback ?: ( ( ) => void ) | undefined ) : Server ;
62
61
/**
63
62
* Asynchronously get the number of concurrent connections on the server.
64
63
*
@@ -68,7 +67,6 @@ export default class Server extends EventEmitter<ServerEvents, any> {
68
67
* @returns {Server }
69
68
*/
70
69
getConnections ( callback : ( err : Error | null , count : number ) => void ) : Server ;
71
-
72
70
/**
73
71
* Stops the server from accepting new connections and keeps existing connections.
74
72
* This function is asynchronous, the server is finally closed when all connections are ended and the server emits a `'close'` event.
@@ -78,8 +76,7 @@ export default class Server extends EventEmitter<ServerEvents, any> {
78
76
* @param {(err?: Error) => void } [callback] Called when the server is closed.
79
77
* @returns {Server }
80
78
*/
81
- close ( callback ?: ( err ?: Error ) => void ) : Server ;
82
-
79
+ close ( callback ?: ( ( err ?: Error | undefined ) => void ) | undefined ) : Server ;
83
80
/**
84
81
* Returns the bound `address`, the address `family` name, and `port` of the server as reported by the operating system if listening
85
82
* on an IP socket (useful to find which port was assigned when getting an OS-assigned address):
@@ -88,26 +85,24 @@ export default class Server extends EventEmitter<ServerEvents, any> {
88
85
* @returns {import('./Socket').AddressInfo | null }
89
86
*/
90
87
address ( ) : import ( './Socket' ) . AddressInfo | null ;
91
-
92
88
ref ( ) : Server ;
93
89
unref ( ) : Server ;
94
-
95
90
/**
96
91
* @private
97
92
*/
98
- private _registerEvents ( ) : void ;
99
-
93
+ private _registerEvents ;
94
+ _listeningListener : import ( "react-native" ) . EmitterSubscription | undefined ;
95
+ _errorListener : import ( "react-native" ) . EmitterSubscription | undefined ;
96
+ _connectionsListener : import ( "react-native" ) . EmitterSubscription | undefined ;
100
97
/**
101
98
* @private
102
99
*/
103
- private _setDisconnected ( ) : void ;
104
-
100
+ private _setDisconnected ;
105
101
/**
106
102
* @protected
107
103
* @param {Socket } socket
108
104
*/
109
105
protected _addConnection ( socket : Socket ) : void ;
110
-
111
106
/**
112
107
* @protected
113
108
* @param {{ id: number; connection: import('./Socket').NativeConnectionInfo; } } info
@@ -117,32 +112,27 @@ export default class Server extends EventEmitter<ServerEvents, any> {
117
112
id : number ;
118
113
connection : import ( './Socket' ) . NativeConnectionInfo ;
119
114
} ) : Socket ;
120
-
121
115
/**
122
116
* Apply server socket options to a newly connected socket
123
117
* @param {Socket } socket
124
118
* @private
125
119
*/
126
- private _applySocketOptions ( socket : Socket ) : void ;
120
+ private _applySocketOptions ;
127
121
}
128
-
129
122
export type ServerOptions = {
130
- noDelay ?: boolean ;
131
- keepAlive ?: boolean ;
132
- keepAliveInitialDelay ?: number ;
133
- allowHalfOpen ?: boolean ;
134
- pauseOnConnect ?: boolean ;
123
+ noDelay ?: boolean | undefined ;
124
+ keepAlive ?: boolean | undefined ;
125
+ keepAliveInitialDelay ?: number | undefined ;
126
+ allowHalfOpen ?: boolean | undefined ;
127
+ pauseOnConnect ?: boolean | undefined ;
135
128
} ;
136
-
137
129
export type TLSSocket = import ( "./TLSSocket" ) . default ;
138
-
139
130
export type ServerEvents = {
140
131
close : ( ) => void ;
141
132
connection : ( socket : Socket ) => void ;
142
133
listening : ( ) => void ;
143
134
error : ( err : Error ) => void ;
144
135
secureConnection : ( tlsSocket : TLSSocket ) => void ;
145
136
} ;
146
-
147
137
import EventEmitter from "eventemitter3" ;
148
- import Socket from "./Socket" ;
138
+ import Socket from "./Socket" ;
0 commit comments