-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathpushcpp_eventloop.cpp
More file actions
40 lines (39 loc) · 1.05 KB
/
pushcpp_eventloop.cpp
File metadata and controls
40 lines (39 loc) · 1.05 KB
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
#include "pushcpp_internal.h"
void pushcpp::Execute() {
if (request_connection_) {
if (this->m_websocket == NULL ||
((WebSocket::pointer)this->m_websocket)->getReadyState()
== WebSocket::CLOSED) {
// logger attempt to connecte
if (this->m_websocket != NULL)
delete((WebSocket::pointer) this->m_websocket);
this->m_websocket = (void*) WebSocket::from_url(m_url);
return;
}
WebSocket::pointer ws = (WebSocket::pointer) this->m_websocket;
// connected log (subs.. resubs..)
if (ws->getReadyState() != WebSocket::CLOSED) {
ws->poll(100);
ws->dispatch([this, ws](const string &msg) {
WS_Dispatch(msg);
});
if (m_wantDisconnect) {
ws->close();
request_connection_ = false;
}
return;
}
// add log connection Lost
this->m_socketId = "";
for (auto it = m_channelData.begin(); it != m_channelData.end(); it++) {
it->second.clear();
}
if (m_connectionEventHandler) {
m_connectionEventHandler(ConnectionEvent::DISCONNECTED);
}
if (m_wantDisconnect) {
m_wantDisconnect = false;
return;
}
}
}