A WebSocket server implementation.
This class implements a WebSocket server that can also support the high-level multiplayer API.
After starting the server (listen), you will need to NetworkedMultiplayerPeer.poll it at regular intervals (e.g. inside Node._process). When clients connect, disconnect, or send data, you will receive the appropriate signal.
Note: Not available in HTML5 exports.
is_listening ( ) const
stop ( )
Emitted when a new client connects. "protocol" will be the sub-protocol agreed with the client.
Emitted when a client disconnects.
was_clean_close will be
true if the connection was shutdown cleanly.
data_received ( int id )
Emitted when a new message is received.
Note: This signal is not emitted when used as high-level multiplayer peer.
String bind_ip =
When not set to
* will restrict incoming connections to the specified IP address. Setting
127.0.0.1 will cause the server to listen only to the local host.
float handshake_timeout =
The time in seconds before a pending client (i.e. a client that has not yet finished the HTTP handshake) is considered stale and forcefully disconnected.
Disconnects the peer identified by
id from the server. See WebSocketPeer.close for more information.
Returns the IP address of the given peer.
Returns the remote port of the given peer.
true if a peer with the given ID is connected.
bool is_listening ( ) const
true if the server is actively listening on a port.
Starts listening on the given port.
You can specify the desired subprotocols via the "protocols" array. If the list empty (default), no sub-protocol will be requested.
false is passed instead (default), you must call PacketPeer functions (
get_packet, etc.), on the WebSocketPeer returned via
get_peer(id) to communicate with the peer with given
void set_extra_headers ( PoolStringArray headers=PoolStringArray( ) )
Sets additional headers to be sent to clients during the HTTP handshake.
void stop ( )
Stops the server and clear its state.