public class WebSocketPeer : PacketPeer
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.
public void Close(int code = 1000, string reason = "")
Closes this WebSocket connection.
codeis the status code for the closure (see RFC 6455 section 7.4 for a list of valid status codes).
reasonis the human readable reason for closing the connection (can be any UTF-8 string that’s smaller than 123 bytes).
public string GetConnectedHost()
Returns the IP address of the connected peer.
public ushort GetConnectedPort()
public WriteMode GetWriteMode()
Gets the current selected write mode. See WriteMode.
public bool IsConnectedToHost()
public void SetWriteMode(WriteMode mode)
Sets the socket to use the given WriteMode.
public bool WasStringPacket()
trueif the last received packet was sent as a text payload. See WriteMode
|Text||0||Specifies that WebSockets messages should be transferred as text payload (only valid UTF-8 is allowed).|
|Binary||1||Specifies that WebSockets messages should be transferred as binary payload (any byte combination is allowed).|