#include <websocketclient.h>
| Public Member Functions | |
| WebSocketClient (WebSocketService &service) | |
| bool | send (const std::string &message, EWebSocketOPCode code, nap::utility::ErrorState &error) | 
| bool | send (void const *payload, int length, EWebSocketOPCode code, nap::utility::ErrorState &error) | 
| bool | send (const WebSocketMessage &message, nap::utility::ErrorState &error) | 
|  Public Member Functions inherited from IWebSocketClient | |
| IWebSocketClient (WebSocketService &service) | |
| virtual bool | init (utility::ErrorState &errorState) override | 
| virtual void | onDestroy () override | 
| bool | isConnected () const | 
| bool | reconnect (utility::ErrorState &error) | 
| const WebSocketConnection & | getConnection () const | 
|  Public Member Functions inherited from WebSocketInterface | |
| WebSocketInterface (WebSocketService &service) | |
| virtual | ~WebSocketInterface () | 
| template<typename T > | |
| T & | as () | 
| template<typename T > | |
| const T & | as () const | 
|  Public Member Functions inherited from Resource | |
| Resource () | |
|  Public Member Functions inherited from Object | |
| Object () | |
| virtual | ~Object () | 
| Object (Object &)=delete | |
| Object & | operator= (const Object &)=delete | 
| Object (Object &&)=delete | |
| Object & | operator= (Object &&)=delete | 
| Additional Inherited Members | |
|  Static Public Member Functions inherited from Object | |
| static bool | isIDProperty (rtti::Instance &object, const rtti::Property &property) | 
|  Public Attributes inherited from IWebSocketClient | |
| ResourcePtr< IWebSocketClientEndPoint > | mEndPoint | 
| Property: 'EndPoint' the client endpoint that manages all connections.  More... | |
| ResourcePtr< WebSocketTicket > | mTicket = nullptr | 
| Property: 'Ticket' optional identification token.  More... | |
| std::string | mURI | 
| Property: "URI" Server URI to open connection to.  More... | |
|  Public Attributes inherited from Object | |
| std::string | mID | 
| Property: 'mID' unique name of the object. Used as an identifier by the system.  More... | |
|  Protected Member Functions inherited from WebSocketInterface | |
| void | addEvent (WebSocketEventPtr newEvent) | 
|  Protected Attributes inherited from IWebSocketClient | |
| WebSocketConnection | mConnection | 
| Web-socket connection.  More... | |
|  Protected Attributes inherited from WebSocketInterface | |
| std::queue< WebSocketEventPtr > | mEvents | 
| std::mutex | mEventMutex | 
| WebSocketService * | mService = nullptr | 
Default implementation of a web-socket client. Converts connection updates and messages into web-socket events. These events are consumed by the nap::WebSocketService on the main application thread. On update all events in the queue are forwarded to a nap::WebSocketComponent. Use a nap::WebSocketComponent to receive and react to web-socket events in your application. On initialization the client registers itself with a nap::WebSocketClientEndPointBase and tries to connect to the server. Call reconnect() to establish a new connection at run-time.
A 'ticket' can be added to specify additional authorization information (username / password). This information is automatically given to the server when the client tries to establish a connection. The server can accept or reject the connection based on that information. When no ticket is provided the client will try to connect without any authorization.
| WebSocketClient | ( | WebSocketService & | service | ) | 
Constructor
| service | the web-socket service that forwards events to the application. | 
| bool send | ( | const std::string & | message, | 
| EWebSocketOPCode | code, | ||
| nap::utility::ErrorState & | error | ||
| ) | 
Sends a message with the given opcode to the server. The message is send immediately.
| message | the message to send | 
| code | message type | 
| error | contains the error if sending fails | 
| bool send | ( | const WebSocketMessage & | message, | 
| nap::utility::ErrorState & | error | ||
| ) | 
Sends a message to the server. The message is send immediately.
| message | the message to send | 
| error | contains the error if sending fails | 
| bool send | ( | void const * | payload, | 
| int | length, | ||
| EWebSocketOPCode | code, | ||
| nap::utility::ErrorState & | error | ||
| ) | 
Sends a message using the given payload and opcode to the server. The message is send immediately.
| payload | the message buffer | 
| length | total number of bytes | 
| code | message type | 
| error | contains the error if sending fails |