Skip to main content

QExpressWebSocketEngine

@quik/websocket-express


@quik/websocket-express / QExpressWebSocketEngine

Class: QExpressWebSocketEngine

Defined in: websocket-express/src/QExpressWebSocketEngine.ts:15

WebSocket engine that attaches a ws server to the active Express HTTP server.

Extends

  • QObject

Implements

  • IQWebSocketEngine

Constructors

Constructor

new QExpressWebSocketEngine(): QExpressWebSocketEngine

Returns

QExpressWebSocketEngine

Inherited from

QObject.constructor

Properties

heartbeat

protected readonly heartbeat: QWebSocketHeartbeatService

Defined in: websocket-express/src/QExpressWebSocketEngine.ts:18


server?

protected optional server?: WebSocketServer

Defined in: websocket-express/src/QExpressWebSocketEngine.ts:16


sockets

protected readonly sockets: Map<string, WebSocket>

Defined in: websocket-express/src/QExpressWebSocketEngine.ts:17

Accessors

engine

Get Signature

get engine(): string

Defined in: websocket-express/src/QExpressWebSocketEngine.ts:30

Name of the underlying WebSocket engine.

Returns

string

Implementation of

IQWebSocketEngine.engine


isListening

Get Signature

get isListening(): boolean

Defined in: websocket-express/src/QExpressWebSocketEngine.ts:40

Indicates whether this engine is bound to the HTTP server.

Returns

boolean

Implementation of

IQWebSocketEngine.isListening


logger

Get Signature

get protected logger(): IQLogger

Defined in: core/src/QObject.ts:15

The logger getter for the object.

Returns

IQLogger

Inherited from

QObject.logger


name

Get Signature

get name(): string

Defined in: core/src/QObject.ts:8

Returns

string

Inherited from

QObject.name


path

Get Signature

get path(): string

Defined in: websocket-express/src/QExpressWebSocketEngine.ts:35

Upgrade path handled by the engine.

Returns

string

Implementation of

IQWebSocketEngine.path

Methods

broadcast()

broadcast(data): number

Defined in: websocket-express/src/QExpressWebSocketEngine.ts:112

Send data to all open connections.

Parameters

data

string

Payload to send.

Returns

number

Implementation of

IQWebSocketEngine.broadcast


endSpan()

protected endSpan(span): void

Defined in: core/src/QObject.ts:35

End a span returned by startSpan.

Parameters

span

TelemetrySpan

The span to end.

Returns

void

Inherited from

QObject.endSpan


handleConnection()

protected handleConnection(websocket): void

Defined in: websocket-express/src/QExpressWebSocketEngine.ts:128

Register one accepted WebSocket connection.

Parameters

websocket

WebSocket

Accepted WebSocket connection.

Returns

void


matchesPath()

protected matchesPath(request): boolean

Defined in: websocket-express/src/QExpressWebSocketEngine.ts:161

Returns true when an upgrade request should be handled by this engine.

Parameters

request

IncomingMessage

HTTP upgrade request.

Returns

boolean


recordSpanError()

protected recordSpanError(span, err): void

Defined in: core/src/QObject.ts:45

Record an exception on an active span.

Parameters

span

TelemetrySpan

The span to record the error on.

err

unknown

The error to record.

Returns

void

Inherited from

QObject.recordSpanError


send()

send(connectionId, data): boolean

Defined in: websocket-express/src/QExpressWebSocketEngine.ts:97

Send data to a single connection.

Parameters

connectionId

string

Connection identifier.

data

string

Payload to send.

Returns

boolean

Implementation of

IQWebSocketEngine.send


setSpanAttribute()

protected setSpanAttribute(span, key, value): void

Defined in: core/src/QObject.ts:64

Set a single attribute on an active span.

Parameters

span

TelemetrySpan

The span to update.

key

string

Attribute key.

value

string | number | boolean

Attribute value.

Returns

void

Inherited from

QObject.setSpanAttribute


start()

start(): Promise<void>

Defined in: websocket-express/src/QExpressWebSocketEngine.ts:47

Start accepting WebSocket upgrades from the active HTTP server.

Returns

Promise<void>

Implementation of

IQWebSocketEngine.start


startSpan()

protected startSpan(spanName, options?): TelemetrySpan

Defined in: core/src/QObject.ts:26

Start a telemetry span for the given operation name. Returns undefined when no telemetry provider is active.

Parameters

spanName

string

Name of the span.

options?

TelemetrySpanOptions

Optional span attributes and kind.

Returns

TelemetrySpan

Inherited from

QObject.startSpan


stop()

stop(): Promise<void>

Defined in: websocket-express/src/QExpressWebSocketEngine.ts:62

Stop accepting WebSocket upgrades and close active peers.

Returns

Promise<void>

Implementation of

IQWebSocketEngine.stop


upgradeListener()

protected readonly upgradeListener(request, socket, head): void

Defined in: websocket-express/src/QExpressWebSocketEngine.ts:19

Parameters

request

IncomingMessage

socket

Duplex

Buffer

Returns

void