Skip to main content
Deno 2 is finally here 🎉️
Learn more
Latest
class Socket
extends EventEmitter<never, never, SocketEvents>
import { Socket } from "https://deno.land/x/socket_io@0.2.0/packages/engine.io/lib/socket.ts";

Constructors

new
Socket(
id: string,
transport: Transport,
)

Properties

private
readonly
opts: ServerOptions
private
optional
pingIntervalTimerId: number
private
optional
pingTimeoutTimerId: number
private
upgradeState: UpgradeState
private
writeBuffer: Packet[]
readonly
id: string
readyState: ReadyState
transport: Transport

Methods

private
bindTransport(transport: Transport)

Attaches handlers for the given transport.

Closes the underlying transport.

private
flush()

Attempts to flush the packets buffer.

private
onClose(reason: CloseReason)

Called upon transport considered closed.

private
onError(err: TransportError)

Called upon transport error.

private
onOpen()

Called upon transport considered open.

private
onPacket(packet: Packet)

Called upon transport packet.

Resets ping timeout.

private
schedulePing()

Pings client every pingInterval and expects response within pingTimeout or closes connection.

private
sendPacket(type: PacketType, data?: RawData)

Sends a packet.

Upgrades socket to the given transport

Closes the socket and underlying transport.

Sends a "message" packet.