JsonObject *Channel::root_json_object = NULL;
ChannelConnectionHandler::ChannelConnectionHandler() {
- pingTimeout = 5000000;
+ pingTimeout = 5000;
lastPingReceived = 0;
running = false;
longestRT = 0;
} else if (timeout == 0) {
connectionHandler->stopPing();
} else {
+ if (isLocalChannel) {
+ MSF_DBG("local channel. startPing was skipped");
+ return;
+ }
connectionHandler->setPingTimeout(timeout);
if (isWebSocketOpen()) {
connectionHandler->startPing(this);
if (onConnectListener) {
onConnectListener->onConnect(clienttemp);
}
+ if (isLocalChannel) {
+ MSF_DBG("local channel. startPing was skipped");
+ return;
+ }
// To start channnel health check
if (isWebSocketOpen()) {
connectionHandler->startPing(this);
}
n = 0;
get_ip_port_from_uri(uri, &server_ip_address, &server_port);
+
+ if (server_ip_address == "127.0.0.1") {
+ isLocalChannel = true;
+ }
string api = getapifromUri(uri);
api.append("channels/").append(ChannelID);
channel_ptr = ptr;
if (pingpongTimer <= 0) {
- pingpongTimer = startTimer(__send_ping_pong, __timeout_worker, pingTimeout/1000, ptr);
+ pingpongTimer = startTimer(__send_ping_pong, __timeout_worker, pingTimeout, ptr);
}
}
long now = time(0);
if (now > ptr->connectionHandler->lastPingReceived +
- ptr->connectionHandler->pingTimeout) {
+ ptr->connectionHandler->pingTimeout/1000) {
MSF_DBG("## Pinging timeout. disconnect ###");
ptr->disconnect();
} else {
stopTimer(ptr->connectionHandler->pingpongTimer);
ptr->connectionHandler->pingpongTimer = 0;
}
- ptr->connectionHandler->pingpongTimer = startTimer(__send_ping_pong, __timeout_worker, ptr->connectionHandler->pingTimeout/1000, ptr);
+ ptr->connectionHandler->pingpongTimer = startTimer(__send_ping_pong, __timeout_worker, ptr->connectionHandler->pingTimeout, ptr);
}
int ChannelConnectionHandler::startTimer(timer_function function, TimerWorker woker, unsigned int interval, void *data)