new Socket(opts)
The client socket.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
Object | The Socket and net.Socket options.
Properties
|
Fires:
Extends
Members
id :String
A unique identifier. It will be set up asynchronously from the server in the event 'connect'.
Type:
- String
Methods
connect()
Connect the socket. The socket will be connected automatically by default
so this method is only useful when you use otps.autoConnect: false,
in the constructor.
- Inherited From:
- Source:
destroy()
Close the socket.
- Inherited From:
- Source:
emit(event, data, paramopt) → {Boolean}
Emit an event.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
event |
String | The event name. | |||||||||||||||||||||
data |
String | Number | Object | Buffer | Boolean | The data to send. | |||||||||||||||||||||
param |
Object | function |
<optional> |
The options or callback.
Properties
|
Returns:
true if the entire data was flushed successfully. false if all or part of
the data was queued in user memory. 'socket_drain' will be emitted when the buffer
is again free.
- Type
- Boolean
end()
Send a FIN packet.
getSerializerVersion() → {Number}
Get the version of the underlying serializer.
- Inherited From:
- Source:
Returns:
The serializer version.
- Type
- Number
join(room)
Join to a room.
Parameters:
Name | Type | Description |
---|---|---|
room |
String | Array.<String> | The room name. |
leave(room)
Leave a room.
Parameters:
Name | Type | Description |
---|---|---|
room |
String | Array.<String> | The room name. |
leaveAll()
Leave all rooms.
setKeepAlive(enableopt, initialDelayopt)
Enable/disable keep-alive functionality, and optionally set the initial delay before the first
keepalive probe is sent on an idle socket.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
enable |
Boolean |
<optional> |
false | True to enable the TCP keep-alive, false to disable it. |
initialDelay |
Number |
<optional> |
0 | Set the delay in milliseconds between the last data packet received and the first keepalive probe. |
- Inherited From:
- Source:
setNoDelay(noDelayopt)
Disables the Nagle algorithm.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
noDelay |
Boolean |
<optional> |
true | True to disable de Nagle algorithm, false to enable it again. |
- Inherited From:
- Source:
setTimeout(timeout)
Sets the socket to timeout after 'timeout' milliseconds of inactivity on the socket.
Parameters:
Name | Type | Description |
---|---|---|
timeout |
Number | The timeout in milliseconds or 0 to disable it. |
- Inherited From:
- Source:
stream(event, data, paramopt) → {stream.Writable}
Creates and returns a stream.Writable instance that can be used to stream
binary data.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
event |
String | The event name. | |||||||||||||||||||||
data |
String | Number | Object | Buffer | Boolean | The data to send along with the stream. | |||||||||||||||||||||
param |
Object | function |
<optional> |
The options or callback.
Properties
|
Returns:
A stream.Writable instance.
- Type
- stream.Writable
Events
close
Close event from net.Socket.
- Inherited From:
- Source:
connect
The socket is connected and registered so Socket#id
now contains the socket identification.
end
End event from net.Socket.
- Inherited From:
- Source:
error
Error event from net.Socket or Socket.
- Inherited From:
- Source:
reconnecting
The socket is trying to reconnect.
- Inherited From:
- Source:
socket_connect
Connected underlying net.Socket, all messages in queue will
be sent and new messages will be sent directly.
- Inherited From:
- Source:
socket_drain
Emitted when the write buffer of the internal socket becomes empty.
Can be used to throttle uploads.
- Inherited From:
- Source: