WebSocketTransport class
Web socket based transport.
Constructors
Web |
Creates a new instance of the WebSocketTransport class. |
Properties
is |
Returns true if the transport is connected to a socket. |
Methods
close() | Close the socket this transport is connected to. |
on |
Sets the transport to attempt to receive incoming data that has not yet arrived. |
receive(number) | Attempt to receive incoming data from the connected socket. |
send(INode |
Sends the given buffer out over the socket's connection. |
Constructor Details
WebSocketTransport(ISocket)
Creates a new instance of the WebSocketTransport class.
new WebSocketTransport(ws: ISocket)
Parameters
- ws
- ISocket
The ISocket to build this transport on top of.
Property Details
isConnected
Returns true if the transport is connected to a socket.
boolean isConnected
Property Value
boolean
true
if the the transport is connected and ready to send data, false
otherwise.
Method Details
close()
Close the socket this transport is connected to.
function close()
onReceive(INodeBuffer)
Sets the transport to attempt to receive incoming data that has not yet arrived.
function onReceive(data: INodeBuffer)
Parameters
- data
- INodeBuffer
A buffer to store incoming data in.
receive(number)
Attempt to receive incoming data from the connected socket.
function receive(count: number): Promise<INodeBuffer>
Parameters
- count
-
number
The number of bytes to attempt to receive.
Returns
Promise<INodeBuffer>
A buffer populated with the received data.
send(INodeBuffer)
Sends the given buffer out over the socket's connection.
function send(buffer: INodeBuffer): number
Parameters
- buffer
- INodeBuffer
The buffered data to send out over the connection.
Returns
number
A number indicating the length of the sent data if the data was successfully sent, otherwise 0.