forked from zeromq/libzmq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzap_client.hpp
74 lines (59 loc) · 1.95 KB
/
zap_client.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* SPDX-License-Identifier: MPL-2.0 */
#ifndef __ZMQ_ZAP_CLIENT_HPP_INCLUDED__
#define __ZMQ_ZAP_CLIENT_HPP_INCLUDED__
#include "mechanism_base.hpp"
namespace zmq
{
class zap_client_t : public virtual mechanism_base_t
{
public:
zap_client_t (session_base_t *session_,
const std::string &peer_address_,
const options_t &options_);
void send_zap_request (const char *mechanism_,
size_t mechanism_length_,
const uint8_t *credentials_,
size_t credentials_size_);
void send_zap_request (const char *mechanism_,
size_t mechanism_length_,
const uint8_t **credentials_,
size_t *credentials_sizes_,
size_t credentials_count_);
virtual int receive_and_process_zap_reply ();
virtual void handle_zap_status_code ();
protected:
const std::string peer_address;
// Status code as received from ZAP handler
std::string status_code;
};
class zap_client_common_handshake_t : public zap_client_t
{
protected:
enum state_t
{
waiting_for_hello,
sending_welcome,
waiting_for_initiate,
waiting_for_zap_reply,
sending_ready,
sending_error,
error_sent,
ready
};
zap_client_common_handshake_t (session_base_t *session_,
const std::string &peer_address_,
const options_t &options_,
state_t zap_reply_ok_state_);
// methods from mechanism_t
status_t status () const ZMQ_FINAL;
int zap_msg_available () ZMQ_FINAL;
// zap_client_t methods
int receive_and_process_zap_reply () ZMQ_FINAL;
void handle_zap_status_code () ZMQ_FINAL;
// Current FSM state
state_t state;
private:
const state_t _zap_reply_ok_state;
};
}
#endif