C++ Rest SDK
The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
Public Member Functions | List of all members
web::websockets::client::websocket_client Class Reference

Websocket client class, used to maintain a connection to a remote host for an extended session. More...

#include <ws_client.h>

Public Member Functions

 websocket_client ()
 Creates a new websocket_client. More...
 
 websocket_client (websocket_client_config config)
 Creates a new websocket_client. More...
 
pplx::task< void > connect (const web::uri &uri)
 Connects to the remote network destination. The connect method initiates the websocket handshake with the remote network destination, takes care of the protocol upgrade request. More...
 
pplx::task< void > send (websocket_outgoing_message msg)
 Sends a websocket message to the server . More...
 
pplx::task< websocket_incoming_messagereceive ()
 Receive a websocket message. More...
 
pplx::task< void > close ()
 Closes a websocket client connection, sends a close frame to the server and waits for a close message from the server. More...
 
pplx::task< void > close (websocket_close_status close_status, const utility::string_t &close_reason=_XPLATSTR(""))
 Closes a websocket client connection, sends a close frame to the server and waits for a close message from the server. More...
 
const web::uriuri () const
 Gets the websocket client URI. More...
 
const websocket_client_configconfig () const
 Gets the websocket client config object. More...
 

Detailed Description

Websocket client class, used to maintain a connection to a remote host for an extended session.

Constructor & Destructor Documentation

web::websockets::client::websocket_client::websocket_client ( )
inline

Creates a new websocket_client.

web::websockets::client::websocket_client::websocket_client ( websocket_client_config  config)
inline

Creates a new websocket_client.

Parameters
configThe client configuration object containing the possible configuration options to initialize the websocket_client.

Member Function Documentation

pplx::task<void> web::websockets::client::websocket_client::close ( )
inline

Closes a websocket client connection, sends a close frame to the server and waits for a close message from the server.

Returns
An asynchronous operation that is completed the connection has been successfully closed.
pplx::task<void> web::websockets::client::websocket_client::close ( websocket_close_status  close_status,
const utility::string_t &  close_reason = _XPLATSTR("") 
)
inline

Closes a websocket client connection, sends a close frame to the server and waits for a close message from the server.

Parameters
close_statusEndpoint MAY use the following pre-defined status codes when sending a Close frame.
close_reasonWhile closing an established connection, an endpoint may indicate the reason for closure.
Returns
An asynchronous operation that is completed the connection has been successfully closed.
const websocket_client_config& web::websockets::client::websocket_client::config ( ) const
inline

Gets the websocket client config object.

Returns
A reference to the client configuration object.
pplx::task<void> web::websockets::client::websocket_client::connect ( const web::uri uri)
inline

Connects to the remote network destination. The connect method initiates the websocket handshake with the remote network destination, takes care of the protocol upgrade request.

Parameters
uriThe uri address to connect.
Returns
An asynchronous operation that is completed once the client has successfully connected to the websocket server.
pplx::task<websocket_incoming_message> web::websockets::client::websocket_client::receive ( )
inline

Receive a websocket message.

Returns
An asynchronous operation that is completed when a message has been received by the client endpoint.
pplx::task<void> web::websockets::client::websocket_client::send ( websocket_outgoing_message  msg)
inline

Sends a websocket message to the server .

Returns
An asynchronous operation that is completed once the message is sent.
const web::uri& web::websockets::client::websocket_client::uri ( ) const
inline

Gets the websocket client URI.

Returns
URI connected to.

The documentation for this class was generated from the following file: