new WebSocketBase()
Base WebSocket implementation.
- Source:
Methods
-
binaryHandlerID() → {string}
-
When a
Websocketis 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
-
close()
-
Close the WebSocket.
- Source:
-
closeHandler(handler) → {WebSocketBase}
-
Set a close handler. This will be called when the WebSocket is closed.
Parameters:
Name Type Description handlerfunction the handler - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- WebSocketBase
-
drainHandler(handler) → {WebSocketBase}
-
Parameters:
Name Type Description handlerfunction - Source:
Returns:
- Type
- WebSocketBase
-
endHandler(endHandler) → {WebSocketBase}
-
Parameters:
Name Type Description endHandlerfunction - Source:
Returns:
- Type
- WebSocketBase
-
exceptionHandler(handler) → {WebSocketBase}
-
Parameters:
Name Type Description handlerfunction - Source:
Returns:
- Type
- WebSocketBase
-
frameHandler(handler) → {WebSocketBase}
-
Set a frame handler on the connection. This handler will be called when frames are read on the connection.
Parameters:
Name Type Description handlerfunction the handler - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- WebSocketBase
-
handler(handler) → {WebSocketBase}
-
Parameters:
Name Type Description handlerfunction - Source:
Returns:
- Type
- WebSocketBase
-
localAddress() → {SocketAddress}
-
- Source:
Returns:
-
the local address for this socket
-
- Type
- SocketAddress
-
pause() → {WebSocketBase}
-
- Source:
Returns:
- Type
- WebSocketBase
-
remoteAddress() → {SocketAddress}
-
- Source:
Returns:
-
the remote address for this socket
-
- Type
- SocketAddress
-
resume() → {WebSocketBase}
-
- Source:
Returns:
- Type
- WebSocketBase
-
setWriteQueueMaxSize(maxSize) → {WebSocketBase}
-
Parameters:
Name Type Description maxSizenumber - Source:
Returns:
- Type
- WebSocketBase
-
textHandlerID() → {string}
-
When a
Websocketis created it automatically registers an event handler with the eventbus, the ID of that handler is given bytextHandlerID.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
-
write(data) → {WebSocketBase}
-
Parameters:
Name Type Description dataBuffer - Source:
Returns:
- Type
- WebSocketBase
-
writeBinaryMessage(data) → {WebSocketBase}
-
Writes a (potentially large) piece of binary data to the connection. This data might be written as multiple frames if it exceeds the maximum WebSocket frame size.
Parameters:
Name Type Description dataBuffer the data to write - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- WebSocketBase
-
writeFinalBinaryFrame(data) → {WebSocketBase}
-
Write a final WebSocket binary frame to the connection
Parameters:
Name Type Description dataBuffer The data to write - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- WebSocketBase
-
writeFinalTextFrame(text) → {WebSocketBase}
-
Write a final WebSocket text frame to the connection
Parameters:
Name Type Description textstring The text to write - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- WebSocketBase
-
writeFrame(frame) → {WebSocketBase}
-
Write a WebSocket frame to the connection
Parameters:
Name Type Description frameWebSocketFrame the frame to write - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- WebSocketBase
-
writeQueueFull() → {boolean}
-
This will return
trueif there are more bytes in the write queue than the value set using WebSocketBase#setWriteQueueMaxSize- Source:
Returns:
true if write queue is full- Type
- boolean