ASL
|
This class represents a WebSocket.
A WebSocket can be used to connect to WebSocket server as a client and send and receive messages (binary or text). Or it can be an incoming connection in a WebSocketServer.
To connect to a TLS secure server, use the "wss:" protocol:
#include <WebSocket.h>
Public Member Functions | |
WebSocket () | |
Creates an unconnected WebSocket. | |
bool | connect (const String &host, int port=80) |
Connecto to a WebSocket server at the given host and port (the port can be in the host string separated with ':') | |
void | close () |
Closes this WebSocket. | |
WebSocketMsg | receive () |
Receives a messege from the peer. | |
void | send (const ByteArray &m) |
Sends a binary message to the peer. | |
void | send (const String &m) |
Sends a text message to the peer. | |
void | send (const Var &v) |
Sends a Var as a text message by encoding to JSON. | |
bool | wait (double timeout=5) |
Waits for incoming data for a maximum time or a disconnection, returns true if something happened before timeout. | |
bool | waitData (double timeout=5) |
Waits for incoming data for a maximum time or a disconnection, returns true only if there is incoming data. | |
bool | hasInput () |
Checks if there is some input available. | |
int | code () const |
Returns the close status code if the socket was closed. | |
bool | closed () |
Tests if this WebSocket is closed, possibly by the other end. | |
bool | connected () |
Tests if this WebSocket is connected. | |