Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/socket_client/mod.ts>WSClient

A simple WebSocket client for Deno
Latest
class WSClient
import { WSClient } from "https://deno.land/x/socket_client@0.1.0-alpha.1/mod.ts";

Constructors

new
WSClient(config: WSConfig)

Properties

readonly
conn

The connection of this client.

fragments: Message[]

The current fragments.

headers: Headers

Headers that will be used when connecting.

lastPong: number

The last time the client received a pong.

logger: Logger

The logger used to log messages.

onclose: WSCloseEvent

The function to handle close event.

onerror: WSErrorEvent

The function to handle error event.

onmessage: WSMessageEvent

The function to handle message event.

onopen: WSOpenEvent

The function to handle open event.

readonly
reader

The current reader for the connection.

state: WSState

The state of the connection.

uri: URL

The uri used to establish the WebSocket connection.

readonly
writer

The current writer for the connection.

Methods

close(options?: CloseOptions)

Close the websocket connection.

Connect to the websocket.

sendFrame(opcode: OpCode, data: Uint8Array)

Send/Write a frame to the websocket.

sendMessage(mes: string | Uint8Array)

Send/Write a message frame to the websocket.