Class SharedWorkerServer<Header, Provider, Remote>

SharedWorker server.

  • available only in the Web Browser.

The SharedWorkerServer is a class representing a server in SharedWorker environment. Clients connecting to the SharedWorkerServer would communicate with this server through SharedWorkerAcceptor instaces using RPC (Remote Procedure Call) concept.

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

Also, when declaring this SharedWorkerServer type, you have to define three generic arguments; Header, Provider and Remote. Those generic arguments would be propagated to the SharedWorkerAcceptor, so that SharedWorkerAcceptor 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 SharedWorkerServer} instance is newly created, but did nothing yet.
    • OPENING: The {@link SharedWorkerServer.open} method is on running.
    • OPEN: The websocket server is online.
    • CLOSING: The {@link SharedWorkerServer.close} method is on running.
    • CLOSED: The websocket server is offline.

    Returns WebSocketServer.State

Methods

  • Close server.

    Close all connections between its remote clients (SharedWorkerConnectors).

    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>