Class: Sock

Sock

Members

id :String

A unique identifier. It will be set up asynchronously from the server in the event 'connect'.
Type:
  • String
Source:

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.
Source:

destroy()

Close the socket.
Source:

end()

Send a FIN packet.
Source:

getSerializerVersion() → {Number}

Get the version of the underlying serializer.
Source:
Returns:
The serializer version.
Type
Number

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.
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.
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.
Source:

Events

close

Close event from net.Socket.
Source:

end

End event from net.Socket.
Source:

error

Error event from net.Socket or Socket.
Source:

reconnecting

The socket is trying to reconnect.
Source:

socket_connect

Connected underlying net.Socket, all messages in queue will be sent and new messages will be sent directly.
Source:

socket_drain

Emitted when the write buffer of the internal socket becomes empty. Can be used to throttle uploads.
Source: