Constructor
new Server(optionsopt, connectionListeneropt)
Creates an instance of Server.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
ServerOpts
|
SocketCallback
|
<optional> |
Options for the server. |
connectionListener |
SocketCallback
|
<optional> |
Register this as the event listener for the 'listening' event, if provided. |
Classes
Methods
_checkClosed()
If all of the clients have closed, clean up and emit the 'close' event.
close(cbopt) → {Server}
Close down all of the clients, then the server.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
cb |
PlainCallback
|
<optional> |
Registered as listener for the 'close' event. |
emit(eventName, …args) → {boolean}
Add debug logging to EventEmitter. Start with NODE_DEBUG=mock-tls-server
to see all events.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
eventName |
string
|
The name of the event. | |
args |
Array.<any>
|
<repeatable> |
The arguments to be passed to listeners. |
Returns:
- Type:
-
boolean
Returns `true` if the event had listeners, `false`
otherwise.
getConnections(cb) → {Server}
Get the number of current clients.
Parameters:
Name | Type | Description |
---|---|---|
cb |
CountCallback
|
Called with the current number of clients. |
Throws:
-
Callback not a function.
- Type
-
TypeError
listen(optionsopt, listeningListeneropt) → {Server}
Listen for incoming connections. Whenever `connect` is called on this
server's port, create a mock socket wrapped in a TLSSocket.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
number
|
ListenOptions
|
<optional> |
Port number or options object. |
listeningListener |
function
|
<optional> |
If it exists, installed as a listener for the 'listening' event. |