Skip to main content

QWebSocketHeartbeatService

@quik/websocket


@quik/websocket / QWebSocketHeartbeatService

Class: QWebSocketHeartbeatService

Defined in: websocket/src/QWebSocketHeartbeatService.ts:18

Tracks WebSocket peers and performs application-level heartbeat checks.

Extends

  • QService

Constructors

Constructor

new QWebSocketHeartbeatService(): QWebSocketHeartbeatService

Returns

QWebSocketHeartbeatService

Inherited from

QService.constructor

Properties

_language?

protected optional _language?: string

Defined in: services/src/QService.ts:17

Inherited from

QService._language


_user

protected _user: IQUser

Defined in: services/src/QService.ts:16

Inherited from

QService._user


connections

protected readonly connections: Map<string, QWebSocketConnectionState>

Defined in: websocket/src/QWebSocketHeartbeatService.ts:19


timer?

protected optional timer?: Timeout

Defined in: websocket/src/QWebSocketHeartbeatService.ts:20

Accessors

language

Get Signature

get protected language(): string

Defined in: services/src/QService.ts:27

Returns

string

Set Signature

set protected language(value): void

Defined in: services/src/QService.ts:31

Parameters
value

string

Returns

void

Inherited from

QService.language


logger

Get Signature

get protected logger(): IQLogger

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

The logger getter for the object.

Returns

IQLogger

Inherited from

QService.logger


name

Get Signature

get name(): string

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

Returns

string

Inherited from

QService.name


options

Get Signature

get options(): IQWebSocketHeartbeatOptions

Defined in: websocket/src/QWebSocketHeartbeatService.ts:25

Returns the heartbeat options from configuration.

Returns

IQWebSocketHeartbeatOptions


user

Get Signature

get protected user(): IQUser

Defined in: services/src/QService.ts:19

Returns

IQUser

Set Signature

set protected user(newUser): void

Defined in: services/src/QService.ts:23

Parameters
newUser

IQUser

Returns

void

Inherited from

QService.user

Methods

all()

all(): IQWebSocketConnection[]

Defined in: websocket/src/QWebSocketHeartbeatService.ts:69

Return all tracked connection adapters.

Returns

IQWebSocketConnection[]


check()

check(now?): void

Defined in: websocket/src/QWebSocketHeartbeatService.ts:167

Execute one heartbeat check cycle.

Parameters

now?

number = ...

Timestamp used for the check.

Returns

void


clear()

clear(): void

Defined in: websocket/src/QWebSocketHeartbeatService.ts:76

Clear all tracked connections.

Returns

void


clone()

clone<T>(properties?): T

Defined in: services/src/QService.ts:40

Creates a clone of the current service.

Type Parameters

T

T extends QService = QService

Parameters

properties?

Record<string, any>

A list of properties that you want to pass to the new instance.

Returns

T

Inherited from

QService.clone


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

QService.endSpan


executeCommand()

protected executeCommand<T>(command, args?): Promise<void>

Defined in: services/src/QService.ts:106

Executes a CLI command if the CLI module is loaded.

Type Parameters

T

T = any

Parameters

command

string

The command to execute.

args?

T

Arguments passed to the command.

Returns

Promise<void>

Inherited from

QService.executeCommand


getLanguageStore()

protected getLanguageStore(): IQI18n

Defined in: services/src/QService.ts:116

Retrieves the i18n store in use by the application.

Returns

IQI18n

Inherited from

QService.getLanguageStore


has()

has(connectionId): boolean

Defined in: websocket/src/QWebSocketHeartbeatService.ts:62

Returns true when a connection is currently tracked.

Parameters

connectionId

string

Connection identifier.

Returns

boolean


hasModule()

protected hasModule(module): boolean

Defined in: services/src/QService.ts:96

Checks if a module has been registered in the bootstrapper.

Parameters

module

string

Returns

boolean

Inherited from

QService.hasModule


init()

init(): Promise<void>

Defined in: services/src/QService.ts:82

Method used to perform some initializations in the class.

Returns

Promise<void>

Inherited from

QService.init


markPong()

markPong(connectionId, pingId?): void

Defined in: websocket/src/QWebSocketHeartbeatService.ts:148

Mark a connection as having answered the latest ping.

Parameters

connectionId

string

Connection identifier.

pingId?

string

Optional ping identifier.

Returns

void


receive()

receive(connectionId, data): boolean

Defined in: websocket/src/QWebSocketHeartbeatService.ts:119

Process an incoming frame and handle heartbeat messages.

Parameters

connectionId

string

Connection identifier.

data

unknown

Incoming frame payload.

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

QService.recordSpanError


register()

register(connection): void

Defined in: websocket/src/QWebSocketHeartbeatService.ts:40

Register a connection for heartbeat checks.

Parameters

connection

IQWebSocketConnection

Connection adapter.

Returns

void


scope()

scope(scope?): QWebSocketHeartbeatService

Defined in: services/src/QService.ts:55

Creates a scoped clone of the current service.

Parameters

scope?

IQServiceScope

The scope applied to the cloned instance.

Returns

QWebSocketHeartbeatService

Inherited from

QService.scope


session()

session(user, properties?): QWebSocketHeartbeatService

Defined in: services/src/QService.ts:75

Creates a session bound to a specific user.

Parameters

user

IQUser

The user to attach to the service instance.

properties?

Record<string, any>

Extra properties applied when cloning the service.

Returns

QWebSocketHeartbeatService

Inherited from

QService.session


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

QService.setSpanAttribute


shutdown()

shutdown(): Promise<void>

Defined in: websocket/src/QWebSocketHeartbeatService.ts:108

Stop heartbeat checks during service shutdown.

Returns

Promise<void>

Overrides

QService.shutdown


start()

start(): void

Defined in: websocket/src/QWebSocketHeartbeatService.ts:83

Start periodic heartbeat checks.

Returns

void


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

QService.startSpan


stop()

stop(): void

Defined in: websocket/src/QWebSocketHeartbeatService.ts:96

Stop periodic heartbeat checks.

Returns

void


translate()

protected translate(key, options): string

Defined in: services/src/QService.ts:126

Helper method to translate a key using the i18n store.

Parameters

key

string

The translation key.

options

Record<string, any>

The interpolation options.

Returns

string

Inherited from

QService.translate


unregister()

unregister(connectionId): void

Defined in: websocket/src/QWebSocketHeartbeatService.ts:53

Remove a connection from heartbeat checks.

Parameters

connectionId

string

Connection identifier.

Returns

void