Skip to main content

Class: SocketIOWebSocketConnection

Represents a WebSocket connection, including the connection details and methods to interact with it.

Implements​

Constructors​

Constructor​

new SocketIOWebSocketConnection(socket): SocketIOWebSocketConnection

Parameters​

socket​

Socket

Returns​

SocketIOWebSocketConnection

Accessors​

connected​

Get Signature​

get connected(): boolean

Whether the underlying transport connection is still open.

Returns​

boolean

Whether the underlying transport connection is still open.

Implementation of​

WebSocketConnection.connected


id​

Get Signature​

get id(): string

Unique identifier for this connection.

Returns​

string

Unique identifier for this connection.

Implementation of​

WebSocketConnection.id


namespace​

Get Signature​

get namespace(): string | undefined

Namespace this connection belongs to, if the adapter supports namespaces.

Returns​

string | undefined

Namespace this connection belongs to, if the adapter supports namespaces.

Implementation of​

WebSocketConnection.namespace


rooms​

Get Signature​

get rooms(): readonly string[]

Rooms/channels this connection currently belongs to, if the adapter supports them.

Returns​

readonly string[]

Rooms/channels this connection currently belongs to, if the adapter supports them.

Implementation of​

WebSocketConnection.rooms

Methods​

broadcast()​

broadcast<TData>(room, event, data?): void

Broadcasts an event to a room (excluding or including self, per adapter convention).

Type Parameters​

TData​

TData = unknown

Parameters​

room​

string

event​

string

data?​

TData

Returns​

void

Implementation of​

WebSocketConnection.broadcast


close()​

close(_code?, _reason?): void

Closes the connection, optionally with a reason code/message.

Parameters​

_code?​

number

_reason?​

string

Returns​

void

Implementation of​

WebSocketConnection.close


emit()​

emit<TData>(event, data?): void

Sends an event with a payload to this connection only.

Type Parameters​

TData​

TData = unknown

Parameters​

event​

string

data?​

TData

Returns​

void

Implementation of​

WebSocketConnection.emit


join()​

join(room): void

Joins a room/channel, if supported by the underlying adapter.

Parameters​

room​

string

Returns​

void

Implementation of​

WebSocketConnection.join


leave()​

leave(room): void

Leaves a room/channel, if supported by the underlying adapter.

Parameters​

room​

string

Returns​

void

Implementation of​

WebSocketConnection.leave