Methods
binaryHandlerID() → {string}
When a
Websocket
is created it automatically registers an event handler with the event bus - the ID of that
handler is given by this method.
Given this ID, a different event loop can send a binary frame to that event handler using the event bus and that buffer will be received by this instance in its own event loop and written to the underlying connection. This allows you to write data to other WebSockets which are owned by different event loops.
- Source:
Returns:
the binary handler id
- Type
- string
binaryMessageHandler(handler) → {WebSocketBase}
Set a binary message handler on the connection. This handler serves a similar purpose to WebSocket#handler
except that if a message comes into the socket in multiple frames, the data from the frames will be aggregated
into a single buffer before calling the handler (using WebSocketFrame#isFinal to find the boundaries).
Parameters:
Name | Type | Description |
---|---|---|
handler |
function | the handler |
- Source:
Returns:
a reference to this, so the API can be used fluently
- Type
- WebSocketBase
close()
Close the WebSocket.
- Source:
closeHandler(handler) → {WebSocket}
Parameters:
Name | Type | Description |
---|---|---|
handler |
function |
- Source:
Returns:
- Type
- WebSocket
drainHandler(handler) → {WebSocket}
Parameters:
Name | Type | Description |
---|---|---|
handler |
function |
- Source:
Returns:
- Type
- WebSocket
end(t)
Same as WebSocketBase#end but writes some data to the stream before ending.
Parameters:
Name | Type | Description |
---|---|---|
t |
Buffer |
- Source:
endHandler(endHandler) → {WebSocket}
Parameters:
Name | Type | Description |
---|---|---|
endHandler |
function |
- Source:
Returns:
- Type
- WebSocket
exceptionHandler(handler) → {WebSocket}
Parameters:
Name | Type | Description |
---|---|---|
handler |
function |
- Source:
Returns:
- Type
- WebSocket
frameHandler(handler) → {WebSocket}
Parameters:
Name | Type | Description |
---|---|---|
handler |
function |
- Source:
Returns:
- Type
- WebSocket
handler(handler) → {WebSocket}
Parameters:
Name | Type | Description |
---|---|---|
handler |
function |
- Source:
Returns:
- Type
- WebSocket
isSsl() → {boolean}
- Source:
Returns:
true if this HttpConnection is encrypted via SSL/TLS.
- Type
- boolean
localAddress() → {SocketAddress}
- Source:
Returns:
the local address for this socket
- Type
- SocketAddress
pause() → {WebSocket}
- Source:
Returns:
- Type
- WebSocket
remoteAddress() → {SocketAddress}
- Source:
Returns:
the remote address for this socket
- Type
- SocketAddress
resume() → {WebSocket}
- Source:
Returns:
- Type
- WebSocket
setWriteQueueMaxSize(maxSize) → {WebSocket}
Parameters:
Name | Type | Description |
---|---|---|
maxSize |
number |
- Source:
Returns:
- Type
- WebSocket
textHandlerID() → {string}
When a
Websocket
is created it automatically registers an event handler with the eventbus, the ID of that
handler is given by textHandlerID
.
Given this ID, a different event loop can send a text frame to that event handler using the event bus and that buffer will be received by this instance in its own event loop and written to the underlying connection. This allows you to write data to other WebSockets which are owned by different event loops.
- Source:
Returns:
- Type
- string
textMessageHandler(handler) → {WebSocketBase}
Set a text message handler on the connection. This handler will be called similar to the
, but the buffer will be converted to a String first
Parameters:
Name | Type | Description |
---|---|---|
handler |
function | the handler |
- Source:
Returns:
a reference to this, so the API can be used fluently
- Type
- WebSocketBase
write(data) → {WebSocket}
Parameters:
Name | Type | Description |
---|---|---|
data |
Buffer |
- Source:
Returns:
- Type
- WebSocket
writeBinaryMessage(data) → {WebSocket}
Parameters:
Name | Type | Description |
---|---|---|
data |
Buffer |
- Source:
Returns:
- Type
- WebSocket
writeFinalBinaryFrame(data) → {WebSocket}
Parameters:
Name | Type | Description |
---|---|---|
data |
Buffer |
- Source:
Returns:
- Type
- WebSocket
writeFinalTextFrame(text) → {WebSocket}
Parameters:
Name | Type | Description |
---|---|---|
text |
string |
- Source:
Returns:
- Type
- WebSocket
writeFrame(frame) → {WebSocket}
Parameters:
Name | Type | Description |
---|---|---|
frame |
WebSocketFrame |
- Source:
Returns:
- Type
- WebSocket
writeQueueFull() → {boolean}
This will return
true
if there are more bytes in the write queue than the value set using WebSocket#setWriteQueueMaxSize
- Source:
Returns:
true if write queue is full
- Type
- boolean
writeTextMessage(text) → {WebSocket}
Parameters:
Name | Type | Description |
---|---|---|
text |
string |
- Source:
Returns:
- Type
- WebSocket