Types
WebSocketClient = ref object
WebSocketIdentifier = cint
WebSocketListener = enum onOpened, onMessage, onClosed, onError
WebSocketServer = ref object id*: cint config*: rtcWsServerConfiguration
Procs
proc close(wsclient: WebSocketClient) {....raises: [], tags: [], forbids: [].}
- Close the WebSocket client
proc close(wsserver: WebSocketServer) {....raises: [], tags: [], forbids: [].}
- Close the WebSocket client
proc getPort(wsserver: WebSocketServer): Port {....raises: [], tags: [], forbids: [].}
- Get the port of the WebSocket server. If there was no port specified, it will return the port assigned by the OS.
proc listen(wsclient: WebSocketClient; event: WebSocketListener; callback: rtcErrorCallbackFunc) {....raises: [], tags: [], forbids: [].}
- Listen for error events on the WebSocket client.
proc listen(wsclient: WebSocketClient; event: WebSocketListener; callback: rtcMessageCallbackFunc) {....raises: [], tags: [], forbids: [].}
- Listen for message events on the WebSocket client.
proc listen(wsclient: WebSocketClient; event: WebSocketListener; callback: rtcOpenCallbackFunc | rtcClosedCallbackFunc)
- Listen for open/closed events on the WebSocket client.
proc message(id: cint; msg: cstring) {....raises: [], tags: [], forbids: [].}
- Send binary data using the WebSocket client.
proc message(id: cint; msg: string) {....raises: [], tags: [], forbids: [].}
- Send a text message
proc message(wsclient: WebSocketClient; msg: string): string {.inline, ...raises: [], tags: [], forbids: [].}
- An alias for send. Send a message using the WebSocket client.
proc newWebSocketClient(url: string; disableTlsVerification: bool = true): WebSocketClient {. ...raises: [], tags: [], forbids: [].}
- Initialize a WebSocket client. If there was no port specified, it will return the port assigned by the OS.
proc newWebSocketServer(enableTls: bool = false; port: Port = Port(0)): WebSocketServer {. ...raises: [], tags: [], forbids: [].}
- Creates a new WebSocketServer. If there was no port specified, it will return the port assigned by the OS.
proc send(id: cint; msg: string) {....raises: [], tags: [], forbids: [].}
- Send binary data using the WebSocket client.
proc send(wsclient: WebSocketClient; message: string) {....raises: [], tags: [], forbids: [].}
- Send a message using the WebSocket client.
proc startServer(wsserver: WebSocketServer; callback: RTCWebSocketClientCallbackFunc): WebSocketIdentifier {. discardable, ...raises: [], tags: [], forbids: [].}
- Start the WebSocket server. Libdatachannel runs the WebSocket server in a separate thread, so you don't need to worry about blocking the main thread.