Class IConnection

Page Contents

Class Documentation

class IConnection

Manages a single connection to a remote endpoint or source server. A connection may be composed of multiple socket connections for purposes of multi-plexing and improved performance.

Public Types

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

Describes a callback function for receiving push notifications from the server.

Public Functions

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

Registers the given callback function to be notified when a message is received from this connection.

Parameters

callback – The callback function to register.

Returns

The iterator of the entry to use when unregistering the callback.

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

Removes the callback with the given iterator.

Parameters

iter – The iterator to unregister, was returned by the original call to AddMessageListener.

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

Initiates a network connection to the given url.

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

Disconnects all active client connections.

virtual void AddSocket(std::shared_ptr<net::IWebSocket> socket, const SocketMode *mode) = 0

Adds the given socket to the connection for monitoring and processing.

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

Transmits the given data buffer to the outgoing connection.