Struct WebSocketPeer

A class representing a specific WebSocket connection.

struct WebSocketPeer ;

This class represent a specific WebSocket connection, you can do lower level operations with it. You can choose to write to the socket in binary or text mode, and you can recognize the mode used for writing by the other peer.

Methods

NameDescription
close Closes this WebSocket connection. code is the status code for the closure (see RFC 6455 section 7.4 for a list of valid status codes). reason is the human readable reason for closing the connection (can be any UTF-8 string that's smaller than 123 bytes). Note: To achieve a clean close, you will need to keep polling until either WebSocketClient.connectionClosed or WebSocketServer.clientDisconnected is received. Note: The HTML5 export might not support all status codes. Please refer to browser-specific documentation for more details.
getConnectedHost Returns the IP address of the connected peer. Note: Not available in the HTML5 export.
getConnectedPort Returns the remote port of the connected peer. Note: Not available in the HTML5 export.
getWriteMode Gets the current selected write mode. See writemode.
isConnectedToHost Returns true if this peer is currently connected.
setWriteMode Sets the socket to use the given writemode.
wasStringPacket Returns true if the last received packet was sent as a text payload. See writemode.

Enums

NameDescription
Constants
WriteMode