Listener: Listener

This is used for creating WebSocket server endpoints. A WebSocket server endpoint is capable of responding to remote callers. The Listener is responsible for initializing the endpoint using the provided configurations.

Constructor

Gets invoked during the module initialization to initialize the listener.

init (int | Listener 'listener, *ListenerConfiguration config)

LifeCycle Methods

attach

Attaches a service to the listener.

Methods

'start

Starts the registered service programmatically.

gracefulStop

Stops the service listener gracefully.

immediateStop

Stops the service listener immediately.

detach

Detaches a WebSocket service from the listener.

attach

function attach(Service websocketService, string[ ] | string? name) returns error?
Isolated Function

Attaches a service to the listener.

Parameters

  • websocketService Service
  • The service that needs to be attached

Return Type

(error?)

An error if an error occurred during the service attachment process or else ()

'start

function 'start() returns error?
Isolated Function

Starts the registered service programmatically.

Return Type

(error?)

An error if an error occurred during the listener starting process

gracefulStop

function gracefulStop() returns error?
Isolated Function

Stops the service listener gracefully. Already-accepted requests will be served before connection closure.

Return Type

(error?)

An error if an error occurred during the listener stopping process

immediateStop

function immediateStop() returns error?
Isolated Function

Stops the service listener immediately. It is not implemented yet.

Return Type

(error?)

An error if an error occurred during the listener stop process

detach

function detach(Service websocketService) returns error?
Isolated Function

Detaches a WebSocket service from the listener. Note that detaching a WebSocket service would not affect The functionality of the existing connections.

Parameters

  • websocketService Service
  • The service to be detached

Return Type

(error?)

An error if one occurred during detaching of a service or else ()