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.Close server.
Close all connections between its remote clients (SharedWorkerConnectors).
It destroys all RFCs (remote function calls) between this server and remote clients
(through Driver<Controller>
) that are not returned (completed) yet. The destruction
causes all incomplete RFCs to throw exceptions.
Open shared worker server.
Open a server through the shared worker protocol, with handler function determining whether to accept the client's connection or not. After the server has been opened, clients can connect to that server by using the SharedWorkerServer class.
When implementing the handler function with the SharedWorkerServer instance, calls the SharedWorkerAcceptor.accept method if you want to accept the new client's connection. Otherwise you don't want to accept the client and reject its connection, just calls the SharedWorkerAcceptor.reject instead.
Callback function called whenever client connects.
SharedWorker server.
The
SharedWorkerServer
is a class representing a server inSharedWorker
environment. Clients connecting to theSharedWorkerServer
would communicate with this server through SharedWorkerAcceptor instances 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
andRemote
. 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 represents an initial data from the remote client after the connection. I recommend utilize it as an activation tool for security enhancement. The second generic argumentProvider
represents a provider from server to client, and the otherRemote
means a provider from the remote client to server.Author
Jeongho Nam - https://github.com/samchon