MetaSoul

Loading...
Searching...
No Matches
sio_client.h
Go to the documentation of this file.
1
2#ifndef EMOSHAPEIO_CLIENT_H
3#define EMOSHAPEIO_CLIENT_H
4#include <string>
5#include <functional>
6#include "sio_message.h"
7#include "sio_socket.h"
8
9 namespace emoshapeio
10{
11 class client_impl_base;
12
13 class EMOSHAPESUBSYSTEM_API client {
14 public:
15 enum close_reason
16 {
17 close_reason_normal,
18 close_reason_drop
19 };
20
21 typedef std::function<void(void)> con_listener;
22
23 typedef std::function<void(close_reason const& reason)> close_listener;
24
25 typedef std::function<void(unsigned, unsigned)> reconnect_listener;
26
27 typedef std::function<void(std::string const& nsp)> socket_listener;
28
29 client();
30
31 client(const bool bShouldUseTlsLibraries, const bool bShouldSkipCertificateVerification);
32
33 ~client();
34
35 //set listeners and event bindings.
36 void set_open_listener(con_listener const& l);
37
38 void set_fail_listener(con_listener const& l);
39
40 void set_reconnecting_listener(con_listener const& l);
41
42 void set_reconnect_listener(reconnect_listener const& l);
43
44 void set_close_listener(close_listener const& l);
45
46 void set_socket_open_listener(socket_listener const& l);
47
48 void set_socket_close_listener(socket_listener const& l);
49
50 void clear_con_listeners();
51
52 void clear_socket_listeners();
53
54 // Client Functions - such as send, etc.
55
56 void connect();
57
58 void connect(const std::string& uri);
59
60 void connect(const std::string& uri, const std::map<std::string,std::string>& query);
61
62 void connect(const std::string& uri, const std::map<std::string,std::string>& query,
63 const std::map<std::string,std::string>& http_extra_headers);
64
65 void set_reconnect_attempts(int attempts);
66
67 void set_reconnect_delay(unsigned millis);
68
69 void set_reconnect_delay_max(unsigned millis);
70
71 void set_path(const std::string& path);
72
73 void set_logs_default();
74
75 void set_logs_quiet();
76
77 void set_logs_verbose();
78
79 emoshapeio::socket::ptr const& socket(const std::string& nsp = "");
80
81 // Closes the connection
82 void close();
83
84 void sync_close();
85
86 // stop io_service
87 void stop();
88
89 bool opened() const;
90
91 std::string const& get_sessionid() const;
92
93 std::string const& get_url() const;
94
95 private:
96 //disable copy constructor and assign operator.
97 client(client const&){}
98 void operator=(client const&){}
99
100 client_impl_base* m_impl;
101
102 std::string m_path;
103 };
104
105}
106
107
108#endif // __SIO_CLIENT__H__
emoshapeio::client
Definition sio_client.h:13
emoshapeio::client::set_socket_close_listener
void set_socket_close_listener(socket_listener const &l)
Definition sio_client.cpp:91
emoshapeio::client::sync_close
void sync_close()
Definition sio_client.cpp:138
emoshapeio::client::close_reason
close_reason
Definition sio_client.h:16
emoshapeio::client::close_reason_normal
@ close_reason_normal
Definition sio_client.h:17
emoshapeio::client::close_reason_drop
@ close_reason_drop
Definition sio_client.h:18
emoshapeio::client::get_sessionid
std::string const & get_sessionid() const
Definition sio_client.cpp:153
emoshapeio::client::set_logs_verbose
void set_logs_verbose()
Definition sio_client.cpp:193
emoshapeio::client::set_logs_default
void set_logs_default()
Definition sio_client.cpp:183
emoshapeio::client::set_reconnect_delay
void set_reconnect_delay(unsigned millis)
Definition sio_client.cpp:163
emoshapeio::client::opened
bool opened() const
Definition sio_client.cpp:143
emoshapeio::client::set_reconnect_delay_max
void set_reconnect_delay_max(unsigned millis)
Definition sio_client.cpp:168
emoshapeio::client::get_url
std::string const & get_url() const
Definition sio_client.cpp:148
emoshapeio::client::client
client()
Definition sio_client.cpp:24
emoshapeio::client::clear_con_listeners
void clear_con_listeners()
Definition sio_client.cpp:96
emoshapeio::client::reconnect_listener
std::function< void(unsigned, unsigned)> reconnect_listener
Definition sio_client.h:25
emoshapeio::client::set_logs_quiet
void set_logs_quiet()
Definition sio_client.cpp:188
emoshapeio::client::connect
void connect()
Definition sio_client.cpp:106
emoshapeio::client::set_open_listener
void set_open_listener(con_listener const &l)
Definition sio_client.cpp:61
emoshapeio::client::connect
void connect(const std::string &uri, const std::map< std::string, std::string > &query)
emoshapeio::client::clear_socket_listeners
void clear_socket_listeners()
Definition sio_client.cpp:101
emoshapeio::client::set_fail_listener
void set_fail_listener(con_listener const &l)
Definition sio_client.cpp:66
emoshapeio::client::set_reconnecting_listener
void set_reconnecting_listener(con_listener const &l)
Definition sio_client.cpp:86
emoshapeio::client::~client
~client()
Definition sio_client.cpp:56
emoshapeio::client::stop
void stop()
Definition sio_client.cpp:178
emoshapeio::client::set_reconnect_attempts
void set_reconnect_attempts(int attempts)
Definition sio_client.cpp:158
emoshapeio::client::set_socket_open_listener
void set_socket_open_listener(socket_listener const &l)
Definition sio_client.cpp:76
emoshapeio::client::close_listener
std::function< void(close_reason const &reason) close_listener)
Definition sio_client.h:23
emoshapeio::client::set_path
void set_path(const std::string &path)
Definition sio_client.cpp:173
emoshapeio::client::socket
emoshapeio::socket::ptr const & socket(const std::string &nsp="")
Definition sio_client.cpp:127
emoshapeio::client::con_listener
std::function< void(void)> con_listener
Definition sio_client.h:21
emoshapeio::client::set_reconnect_listener
void set_reconnect_listener(reconnect_listener const &l)
Definition sio_client.cpp:81
emoshapeio::client::set_close_listener
void set_close_listener(close_listener const &l)
Definition sio_client.cpp:71
emoshapeio::client::close
void close()
Definition sio_client.cpp:133
emoshapeio::client::socket_listener
std::function< void(std::string const &nsp) socket_listener)
Definition sio_client.h:27
emoshapeio::socket::ptr
std::shared_ptr< socket > ptr
Definition sio_socket.h:57
emoshapeio
Definition sio_client_impl.cpp:51
sio_message.h
sio_socket.h