Websocket client class, used to maintain a connection to a remote host for an extended session, uses callback APIs for handling receive and close event instead of async task. For some scenarios would be a alternative for the websocket_client like if you want to special handling on close event.
More...
#include <ws_client.h>
Websocket client class, used to maintain a connection to a remote host for an extended session, uses callback APIs for handling receive and close event instead of async task. For some scenarios would be a alternative for the websocket_client like if you want to special handling on close event.
_ASYNCRTIMP web::websockets::client::websocket_callback_client::websocket_callback_client |
( |
| ) |
|
_ASYNCRTIMP web::websockets::client::websocket_callback_client::websocket_callback_client |
( |
websocket_client_config |
client_config | ) |
|
pplx::task<void> web::websockets::client::websocket_callback_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_callback_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_status | Endpoint MAY use the following pre-defined status codes when sending a Close frame. |
close_reason | While 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.
Gets the websocket client config object.
- Returns
- A reference to the client configuration object.
pplx::task<void> web::websockets::client::websocket_callback_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
-
uri | The uri address to connect. |
- Returns
- An asynchronous operation that is completed once the client has successfully connected to the websocket server.
Sends a websocket message to the server .
- Returns
- An asynchronous operation that is completed once the message is sent.
void web::websockets::client::websocket_callback_client::set_close_handler |
( |
const std::function< void(websocket_close_status close_status, const utility::string_t &reason, const std::error_code &error)> & |
handler | ) |
|
|
inline |
Set the closed handler for notification of client websocket closing event.
- Parameters
-
handler | The handler for websocket closing event, It's parameters are: close_status: The pre-defined status codes used by the endpoint when sending a Close frame. reason: The reason string used by the endpoint when sending a Close frame. error: The error code if the websocket is closed with abnormal error. |
void web::websockets::client::websocket_callback_client::set_message_handler |
( |
const std::function< void(const websocket_incoming_message &msg)> & |
handler | ) |
|
|
inline |
Set the received handler for notification of client websocket messages.
- Parameters
-
handler | A function representing the incoming websocket messages handler. It's parameters are: msg: a websocket_incoming_message value indicating the message received |
If this handler is not set before connecting incoming messages will be missed.
const web::uri& web::websockets::client::websocket_callback_client::uri |
( |
| ) |
const |
|
inline |
Gets the websocket client URI.
- Returns
- URI connected to.
The documentation for this class was generated from the following file: