Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/sockets/mod.ts>Transmitter

A WebSocket library for Deno.
Latest
class Transmitter
import { Transmitter } from "https://deno.land/x/sockets@v0.5.0/mod.ts";

The Transmitter class is used as the middleman between the client and server, when sending messages, to connect the 'wires' between them.

Constructors

new
Transmitter(server: Server, options?: ITransmitterOptions)

Construct an object of this class.

Properties

private
ping_interval: number | undefined

See ITransmitterOptions

private
ping_timeout: number | undefined

See ITransmitterOptions

private
reconnect: boolean | undefined

See ITransmitterOptions

private
server: Server

A property to hold the socket server.

Methods

private
ping(clientId: number): void

Pings client at a set interval.

private
startHeartbeat(clientId: number): number

Start a heartbeat for the client in question.

private
timeoutPing(clientId: number): void

Pings client at a timeout. If client does not respond, client connection will be removed.

handlePacket(packet: Packet): Promise<void>

Decodes and validates incoming messages.

Handles connection states, and actions based on those states.

hydrateClient(clientId: number): void

Hydrate the client with properties.