WebSocketServer¶
WebSocket protocol handler that manages handshaking, framing, and connection lifecycle for a single WebSocket connection.
This class is NOT an actor — it lives inside the user's actor and
handles protocol details. The user's actor implements
WebSocketServerActor and stores this class as a field.
Use none() as the field default so that this is ref in the
actor constructor body, then replace with create() or ssl():
actor MyHandler is WebSocketServerActor
var _ws: WebSocketServer = WebSocketServer.none()
new create(auth: lori.TCPServerAuth, fd: U32,
config: WebSocketConfig val)
=>
_ws = WebSocketServer(auth, fd, this, config)
fun ref _websocket(): WebSocketServer => _ws
Implements¶
Constructors¶
none¶
Create a placeholder protocol instance.
Used as the default value for the _ws field in
WebSocketServerActor implementations, allowing this to be ref
in the actor constructor body. The placeholder is immediately
replaced by create() or ssl() — its methods must never be
called.
Returns¶
- WebSocketServer ref^
create¶
Create a plain WebSocket (WS) connection handler.
new ref create(
auth: TCPServerAuth val,
fd: U32 val,
server_actor: WebSocketServerActor ref,
config: WebSocketConfig val)
: WebSocketServer ref^
Parameters¶
- auth: TCPServerAuth val
- fd: U32 val
- server_actor: WebSocketServerActor ref
- config: WebSocketConfig val
Returns¶
- WebSocketServer ref^
ssl¶
Create a secure WebSocket (WSS) connection handler.
new ref ssl(
auth: TCPServerAuth val,
ssl_ctx: SSLContext val,
fd: U32 val,
server_actor: WebSocketServerActor ref,
config: WebSocketConfig val)
: WebSocketServer ref^
Parameters¶
- auth: TCPServerAuth val
- ssl_ctx: SSLContext val
- fd: U32 val
- server_actor: WebSocketServerActor ref
- config: WebSocketConfig val
Returns¶
- WebSocketServer ref^
Public Functions¶
send_text¶
Send a text message to the client.
Parameters¶
- data: String val
Returns¶
- None val
send_binary¶
Send a binary message to the client.
Parameters¶
Returns¶
- None val
close¶
Initiate a close handshake with the client.
Sends a close frame and transitions to the Closing state. The connection will close after the client responds with its own close frame, or if TCP drops.
fun ref close(
code: (CloseNormal val | CloseGoingAway val | CloseProtocolError val |
CloseUnsupportedData val | CloseInvalidPayload val | ClosePolicyViolation val |
CloseMessageTooBig val | CloseInternalError val) = reference,
reason: String val = "")
: None val
Parameters¶
- code: (CloseNormal val | CloseGoingAway val | CloseProtocolError val | CloseUnsupportedData val | CloseInvalidPayload val | ClosePolicyViolation val | CloseMessageTooBig val | CloseInternalError val) = reference
- reason: String val = ""
Returns¶
- None val