Class WebSocketServer<Header, Provider, Remote>

Web Socket Server.

  • available only in the NodeJS.

The WebSocketServer is a class who can open an websocket server. Clients connecting to the WebSocketServer would communicate with this websocket server through WebSocketAcceptor instances with RPC (Remote Procedure Call) concept.

To open the websocket server, call the open method with your callback function which would be called whenever a WebSocketAcceptor has been newly created by a new client's connection.

Also, when declaring this WebSocketServer type, you have to define three generic arguments; Header, Provider and Remote. Those generic arguments would be propagated to the WebSocketAcceptor, so that WebSocketAcceptor would have the same generic arguments, too.

For reference, the first Header type repersents an initial data from the remote client after the connection. I recommend utilize it as an activation tool for security enhancement. The second generic argument Provider represents a provider from server to client, and the other Remote means a provider from the remote client to server.

Jeongho Nam - https://github.com/samchon

Type Parameters

  • Header

    Type of header containing initialization data like activation.

  • Provider extends object | null

    Type of features provided for the remote client.

  • Remote extends object | null

    Type of features provided by remote client.

Implements

Constructors

Accessors

Methods

Constructors

Accessors

  • get state(): WebSocketServer.State
  • Get server state.

    Get current state of the websocket server.

    List of values are such like below:

    • NONE: The `{@link WebSocketServer} instance is newly created, but did nothing yet.
    • OPENING: The {@link WebSocketServer.open} method is on running.
    • OPEN: The websocket server is online.
    • CLOSING: The {@link WebSocketServer.close} method is on running.
    • CLOSED: The websocket server is offline.

    Returns WebSocketServer.State

Methods

  • Close server.

    Close all connections between its remote clients (WebSocketConnectors).

    It destories all RFCs (remote function calls) between this server and remote clients (through Driver<Controller>) that are not returned (completed) yet. The destruction causes all incompleted RFCs to throw exceptions.

    Returns Promise<void>