Default Constructor for the ws
server..
Create an websocket server (ws://
).
Initializer Constructor for the wss
server.
Create a secured websocket server (wss://
).
Key string.
Certification string.
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.Close server.
Close all connections between its remote clients (WebSocketConnectors).
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 websocket server.
Open a server through the web-socket protocol, with its port number and handler function determining whether to accept the client's connection or not. After the server has been opened, clients can connect to that websocket server by using the WebSocketConnector class.
When implementing the handler function with the WebSocketAcceptor instance, calls the WebSocketAcceptor.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 WebSocketAcceptor.reject instead.
Port number to listen.
Callback function for client connection.
Web Socket Server.
The
WebSocketServer
is a class who can open an websocket server. Clients connecting to theWebSocketServer
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
andRemote
. 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 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