Class IWebSocket

Inheritance Relationships

Derived Type

Class Documentation

class IWebSocket

Provides an abstracted interface for working with WebSocket connections.

Subclassed by axr::sdk::net::WsppWebSocket

Public Types

typedef std::function<void(WebSocketCloseStatus, const utility::string_t&)> CloseCallback

Defines a callback function for handling close events.

typedef std::function<void(std::shared_ptr<IWebSocketMessage>)> MessageCallback

Defines a callback function for handling message events. Warning: The provided IWebSocketMessage argument will go out of scope once the callback completes.

Public Functions

virtual std::vector<CloseCallback>::const_iterator AddCloseHandler(CloseCallback callback) = 0

Registers the given callback function to be notified whenever a socket close event occurs.

Parameters

callback – The callback function to notify on close events.

Returns

The iterator referencing the registered callback. Use this to unregister the callback.

virtual void RemoveCloseHandler(std::vector<CloseCallback>::const_iterator iter) = 0

Unregisters the callback function at the given iterator. The iterator is provided from the AddCloseHandler function.

Parameters

iter – The iterator referencing the callback function to unregister.

virtual std::vector<MessageCallback>::const_iterator AddMessageHandler(MessageCallback callback) = 0

Registers the given callback function to be notified whenever a socket message event occurs.

Parameters

callback – The callback function to notify on message events.

Returns

The iterator referencing the registered callback. Use this to unregister the callback.

virtual void RemoveMessageHandler(std::vector<MessageCallback>::const_iterator iter) = 0

Unregisters the callback function at the given iterator. The iterator is provided from the AddMessageHandler function.

Parameters

iter – The iterator referencing the callback function to unregister.

virtual pplx::task<void> Connect(utility::string_t uri) = 0

Initiates a connection to the remote server at the given uri.

Parameters

uri – The URI of the remote server to connect to.

virtual pplx::task<void> Close() = 0

Terminates the active socket connection with the remote server.

virtual WebSocketStatus GetStatus() = 0

Returns the current status of the connection with the remote server.

virtual pplx::task<void> Send(std::shared_ptr<IWebSocketMessage> message) = 0

Sends the given message to the server through this connection.

Parameters

message – The message to send.