37#include <sio_client.h>
39#ifdef NDEVR_SUPPORTS_SOCKET_IO
46 class SocketIOChannel;
52 explicit SocketIO(QObject *parent = 0);
55 static DynamicPointer<SocketIO> GetSocketIO(
const String& url =
"http://ndevr.org:3000");
56 void setName(
const String& name);
57 void setRunID(
const UUID& run_id);
58 bool connect(
const String& url =
"http://ndevr.org:3000");
60 DynamicPointer<SocketIOChannel> createChannel(
const String& name, UUID target = Constant<UUID>::NaN);
61 DynamicPointer<SocketIOChannel> createChannel(
const String& name, std::function<
void(
const char* data, uint04 size)> data_callback, UUID target = Constant<UUID>::NaN);
62 void addChannel(DynamicPointer<SocketIOChannel>& channel);
63 void removeChannel(DynamicPointer<SocketIOChannel>& channel);
64 const Dictionary<UUID, String>& onlineClients()
const;
65 bool isConnected()
const {
return m_is_connected; }
66 const String& url()
const {
return m_url; }
68 void OnNewMessage(std::string
const& name, message::ptr
const& data,
bool hasAck, message::list &ack_resp);
69 void OnUserJoined(std::string
const& name, message::ptr
const& data,
bool hasAck, message::list &ack_resp);
70 void OnUserLeft(std::string
const& name, message::ptr
const& data,
bool hasAck, message::list &ack_resp);
71 void OnLogin(std::string
const& name, message::ptr
const& data,
bool hasAck, message::list &ack_resp);
72 void OnConnected(std::string
const& nsp);
73 void OnClosed(client::close_reason
const& reason);
76 std::unique_ptr<client> _io;
77 Dictionary<UUID, String> m_online_users;
80 String m_url =
"ws://localhost:3000";
81 Dictionary<String, DynamicPointer<SocketIOChannel>> m_socket_channels;
82 static Dictionary<String, DynamicPointer<SocketIO>> s_server_channels;