Listener: Listener

Represents a Service listener endpoint.

Constructor

Initiliazes the websubhub:Listener instance.

1listener websubhub:Listener hubListenerEp = check new (9090);
init (int | Listener listenTo, *ListenerConfiguration config)
  • listenTo int | Listener
  • Port number or an http:Listener instance

  • config *ListenerConfiguration
  • Custom websubhub:ListenerConfiguration to be provided to the underlying HTTP listener

LifeCycle Methods

attach

Attaches the provided websubhub:Service to the websubhub:Listener.

Methods

detach

Detaches the provided websubhub:Service from the websubhub:Listener.

'start

Starts the registered service programmatically.

gracefulStop

Gracefully stops the hub listener.

immediateStop

Stops the service listener immediately.

attach

function attach(Service 'service, string[ ] | string? name) returns Error?
Isolated Function

Attaches the provided websubhub:Service to the websubhub:Listener.

1check hubListenerEp.attach('service, "/hub");

Parameters

  • 'service Service
  • The websubhub:Service object to attach

  • name string[ ] | string? (default ())
  • The path of the service to be hosted

Return Type

(Error?)

An websubhub:Error if an error occurred during the service attaching process or else ()

detach

function detach(Service s) returns Error?
Isolated Function

Detaches the provided websubhub:Service from the websubhub:Listener.

1check hubListenerEp.detach('service);

Parameters

  • s Service
  • The websubhub:Service object to be detached

Return Type

(Error?)

An websubhub:Error if an error occurred during the service detaching process or else ()

'start

function 'start() returns Error?
Isolated Function

Starts the registered service programmatically.

1check hubListenerEp.'start();

Return Type

(Error?)

An websubhub:Error if an error occurred during the listener-starting process or else ()

gracefulStop

function gracefulStop() returns Error?
Isolated Function

Gracefully stops the hub listener. Already-accepted requests will be served before the connection closure.

1check hubListenerEp.gracefulStop();

Return Type

(Error?)

An websubhub: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.

1check hubListenerEp.immediateStop();

Return Type

(Error?)

An websubhub:Error if an error occurred during the listener-stopping process or else ()