WebSocketServer

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.

Members

Aliases

BaseClasses
alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses)
Undocumented in source.

Functions

disconnectPeer
void disconnectPeer(long id, long code, String reason)

Disconnects the peer identified by id from the server. See WebSocketPeer.close for more information.

getBindIp
String getBindIp()
getCaChain
Ref!X509Certificate getCaChain()
getPeerAddress
String getPeerAddress(long id)

Returns the IP address of the given peer.

getPeerPort
long getPeerPort(long id)

Returns the remote port of the given peer.

getPrivateKey
Ref!CryptoKey getPrivateKey()
getSslCertificate
Ref!X509Certificate getSslCertificate()
hasPeer
bool hasPeer(long id)

Returns true if a peer with the given ID is connected.

isListening
bool isListening()

Returns true if the server is actively listening on a port.

listen
GodotError listen(long port, PoolStringArray protocols, bool gd_mp_api)

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. If true is passed as gd_mp_api, the server will behave like a network peer for the MultiplayerAPI, connections from non-Godot clients will not work, and dataReceived will not be emitted. If false is passed instead (default), you must call PacketPeer functions (put_packet, get_packet, etc.), on the WebSocketPeer returned via get_peer(id) to communicate with the peer with given id (e.g. get_peer(id).get_available_packet_count).

opAssign
typeof(null) opAssign(typeof(null) n)
opEquals
bool opEquals(WebSocketServer other)
opEquals
bool opEquals(typeof(null) n)
setBindIp
void setBindIp(String arg0)
setCaChain
void setCaChain(X509Certificate arg0)
setPrivateKey
void setPrivateKey(CryptoKey arg0)
setSslCertificate
void setSslCertificate(X509Certificate arg0)
stop
void stop()

Stops the server and clear its state.

toHash
size_t toHash()

Mixins

__anonymous
mixin baseCasts
Undocumented in source.

Properties

bindIp
String bindIp [@property getter]
String bindIp [@property setter]

When not set to * will restrict incoming connections to the specified IP address. Setting bind_ip to 127.0.0.1 will cause the server to listen only to the local host.

caChain
X509Certificate caChain [@property getter]
X509Certificate caChain [@property setter]

When using SSL (see privateKey and sslCertificate), you can set this to a valid X509Certificate to be provided as additional CA chain information during the SSL handshake.

privateKey
CryptoKey privateKey [@property getter]
CryptoKey privateKey [@property setter]

When set to a valid CryptoKey (along with sslCertificate) will cause the server to require SSL instead of regular TCP (i.e. the wss:// protocol).

sslCertificate
X509Certificate sslCertificate [@property getter]
X509Certificate sslCertificate [@property setter]

When set to a valid X509Certificate (along with privateKey) will cause the server to require SSL instead of regular TCP (i.e. the wss:// protocol).

Static functions

_new
WebSocketServer _new()

Construct a new instance of WebSocketServer. Note: use memnew!WebSocketServer instead.

Static variables

_classBindingInitialized
bool _classBindingInitialized;
Undocumented in source.

Structs

GDNativeClassBinding
struct GDNativeClassBinding
Undocumented in source.

Unions

__anonymous
union __anonymous
Undocumented in source.

Variables

_GODOT_internal_name
enum string _GODOT_internal_name;
Undocumented in source.

Mixed In Members

From mixin baseCasts

as
inout(To) as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
inout(To) as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
inout(ToRef) as()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(ToRef)
Undocumented in source.
opCast
void* opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
godot_object opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
bool opCast()
Undocumented in source. Be warned that the author may not have intended to support it.

Meta