55 * @property {number } [keepAliveInitialDelay]
66 * @property {boolean } [allowHalfOpen]
77 * @property {boolean } [pauseOnConnect]
8- *
8+ *
99 * @typedef {import('./TLSSocket').default } TLSSocket
1010 *
1111 * @typedef {object } ServerEvents
@@ -22,24 +22,22 @@ export default class Server extends EventEmitter<ServerEvents, any> {
2222 * @param {ServerOptions | ((socket: Socket) => void) } [options] Server options or connection listener
2323 * @param {(socket: Socket) => void } [connectionCallback] Automatically set as a listener for the `'connection'` event.
2424 */
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 ) ;
2726 /** @protected @readonly */
2827 protected readonly _id : number ;
2928 /** @protected @readonly */
3029 protected readonly _eventEmitter : import ( "react-native" ) . EventEmitter ;
3130 /** @private @type {Set<Socket> } */
32- private _connections : Set < Socket > ;
33- /** @private */
34- private _localAddress : string | undefined ;
31+ private _connections ;
3532 /** @private */
36- private _localPort : number | undefined ;
33+ private _localAddress ;
3734 /** @private */
38- private _localFamily : string | undefined ;
35+ private _localPort ;
3936 /** @private */
40- private _serverOptions : ServerOptions ;
37+ private _localFamily ;
38+ /** @private @type {ServerOptions } */
39+ private _serverOptions ;
4140 listening : boolean ;
42-
4341 /**
4442 * Start a server listening for connections.
4543 *
@@ -50,15 +48,16 @@ export default class Server extends EventEmitter<ServerEvents, any> {
5048 * `server.listen()` call or `server.close()` has been called. Otherwise, an `ERR_SERVER_ALREADY_LISTEN`
5149 * error will be thrown.
5250 *
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
5654 * @returns {Server }
5755 */
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 ;
6261 /**
6362 * Asynchronously get the number of concurrent connections on the server.
6463 *
@@ -68,7 +67,6 @@ export default class Server extends EventEmitter<ServerEvents, any> {
6867 * @returns {Server }
6968 */
7069 getConnections ( callback : ( err : Error | null , count : number ) => void ) : Server ;
71-
7270 /**
7371 * Stops the server from accepting new connections and keeps existing connections.
7472 * 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> {
7876 * @param {(err?: Error) => void } [callback] Called when the server is closed.
7977 * @returns {Server }
8078 */
81- close ( callback ?: ( err ?: Error ) => void ) : Server ;
82-
79+ close ( callback ?: ( ( err ?: Error | undefined ) => void ) | undefined ) : Server ;
8380 /**
8481 * Returns the bound `address`, the address `family` name, and `port` of the server as reported by the operating system if listening
8582 * 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> {
8885 * @returns {import('./Socket').AddressInfo | null }
8986 */
9087 address ( ) : import ( './Socket' ) . AddressInfo | null ;
91-
9288 ref ( ) : Server ;
9389 unref ( ) : Server ;
94-
9590 /**
9691 * @private
9792 */
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 ;
10097 /**
10198 * @private
10299 */
103- private _setDisconnected ( ) : void ;
104-
100+ private _setDisconnected ;
105101 /**
106102 * @protected
107103 * @param {Socket } socket
108104 */
109105 protected _addConnection ( socket : Socket ) : void ;
110-
111106 /**
112107 * @protected
113108 * @param {{ id: number; connection: import('./Socket').NativeConnectionInfo; } } info
@@ -117,32 +112,27 @@ export default class Server extends EventEmitter<ServerEvents, any> {
117112 id : number ;
118113 connection : import ( './Socket' ) . NativeConnectionInfo ;
119114 } ) : Socket ;
120-
121115 /**
122116 * Apply server socket options to a newly connected socket
123117 * @param {Socket } socket
124118 * @private
125119 */
126- private _applySocketOptions ( socket : Socket ) : void ;
120+ private _applySocketOptions ;
127121}
128-
129122export 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 ;
135128} ;
136-
137129export type TLSSocket = import ( "./TLSSocket" ) . default ;
138-
139130export type ServerEvents = {
140131 close : ( ) => void ;
141132 connection : ( socket : Socket ) => void ;
142133 listening : ( ) => void ;
143134 error : ( err : Error ) => void ;
144135 secureConnection : ( tlsSocket : TLSSocket ) => void ;
145136} ;
146-
147137import EventEmitter from "eventemitter3" ;
148- import Socket from "./Socket" ;
138+ import Socket from "./Socket" ;
0 commit comments