Handshaker.hpp

This File On Github
Ask A Question

API: latest
module: oatpp-websocket
#include "oatpp-websocket/Handshaker.hpp"

Handshaker

Helper class providing WebSocket handshake functionality.

namespace oatpp { namespace websocket { 
  class Handshaker {}
}}

Typedefs

Type Name Summary
oatpp::web::protocol::http::outgoing::Response OutgoingResponse Convenience typedef for oatpp::web::protocol::http::outgoing::Response.
oatpp::web::protocol::http::incoming::Response IncomingResponse Convenience typedef for oatpp::web::protocol::http::incoming::Response.

Fields

Type Name Summary
v_int32 STATUS_OK Handshake OK.
v_int32 STATUS_SERVER_ERROR Server response-code != 101.
v_int32 STATUS_SERVER_WRONG_KEY Server response "Sec-WebSocket-Accept" header is wrong.
v_int32 STATUS_UNKNOWN_PROTOCOL_SUGGESTED Server's response contains unexpected headers values

Methods

Return Type Name Summary
std::shared_ptr<OutgoingResponse> serversideHandshake Prepare OutgoingResponse as for websocket-handshake based on requestHeaders.
void clientsideHandshake Set client request headers as for websocket-handshake.
v_int32 clientsideConfirmHandshake Check if client's handshake corresponds to server's handshake

Handshaker::OutgoingResponse

Convenience typedef for oatpp::web::protocol::http::outgoing::Response.

typedef oatpp::web::protocol::http::outgoing::Response OutgoingResponse

Handshaker::IncomingResponse

Convenience typedef for oatpp::web::protocol::http::incoming::Response.

typedef oatpp::web::protocol::http::incoming::Response IncomingResponse

Handshaker::STATUS_OK

Handshake OK.

static constexpr v_int32 STATUS_OK = 0

Handshaker::STATUS_SERVER_ERROR

Server response-code != 101.

static constexpr v_int32 STATUS_SERVER_ERROR = 1

Handshaker::STATUS_SERVER_WRONG_KEY

Server response "Sec-WebSocket-Accept" header is wrong.

static constexpr v_int32 STATUS_SERVER_WRONG_KEY = 2

Handshaker::STATUS_UNKNOWN_PROTOCOL_SUGGESTED

Server's response contains unexpected headers values

static constexpr v_int32 STATUS_UNKNOWN_PROTOCOL_SUGGESTED = 3

Handshaker::serversideHandshake

Prepare OutgoingResponse as for websocket-handshake based on requestHeaders.

static std::shared_ptr<OutgoingResponse> serversideHandshake(const Headers& requestHeaders, const std::shared_ptr<ConnectionHandler>& connectionUpgradeHandler)

Handshaker::clientsideHandshake

Set client request headers as for websocket-handshake.

static void clientsideHandshake(Headers& requestHeaders)

Handshaker::clientsideConfirmHandshake

Check if client's handshake corresponds to server's handshake

static v_int32 clientsideConfirmHandshake(const Headers& clientHandshakeHeaders, const std::shared_ptr<IncomingResponse>& serverResponse)