adjust protocoll
This commit is contained in:
1 parent
ff179ee3a4
commit
0612afb37b
3 files changed
+17
-15
No files matched your search
+15
-12
@@ -43,17 +43,23 @@ void Websocket::onClientMessageCallback(const ix::WebSocketMessagePtr &msg)
|
||||
|
||||
toLog(debug_msg.str());
|
||||
|
||||
webSocket->send("LOGIN:" + user);
|
||||
webSocket->send("MASTER:" + user);
|
||||
toLog("Connecting as " + user);
|
||||
} else if (msg->type == ix::WebSocketMessageType::Close) {
|
||||
std::stringstream debug_msg;
|
||||
if (msg->closeInfo.reason.compare("DUPLICATE")) {
|
||||
webSocket->disableAutomaticReconnection();
|
||||
|
||||
debug_msg << "Connection closed" << std::endl;
|
||||
debug_msg << "Code: " << msg->closeInfo.code << std::endl;
|
||||
debug_msg << "Reason: " << msg->closeInfo.reason << std::endl;
|
||||
debug_msg << "Remote: " << msg->closeInfo.remote << std::endl;
|
||||
toLog("Disconnected due to beeing a duplicate simualtor");
|
||||
} else {
|
||||
std::stringstream debug_msg;
|
||||
|
||||
toLog(debug_msg.str());
|
||||
debug_msg << "Connection closed" << std::endl;
|
||||
debug_msg << "Code: " << msg->closeInfo.code << std::endl;
|
||||
debug_msg << "Reason: " << msg->closeInfo.reason << std::endl;
|
||||
debug_msg << "Remote: " << msg->closeInfo.remote << std::endl;
|
||||
|
||||
toLog(debug_msg.str());
|
||||
}
|
||||
} else if (msg->type == ix::WebSocketMessageType::Error) {
|
||||
std::stringstream debug_msg;
|
||||
|
||||
@@ -73,7 +79,7 @@ void Websocket::onClientMessageCallback(const ix::WebSocketMessagePtr &msg)
|
||||
}
|
||||
}
|
||||
|
||||
void Websocket::sendData(data d)
|
||||
void Websocket::sendData(data &d)
|
||||
{
|
||||
if (strcmp(d.path, lastPath) != 0) {
|
||||
strcpy(lastPath, d.path);
|
||||
@@ -94,11 +100,8 @@ void Websocket::sendData(data d)
|
||||
};
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(wsLock);
|
||||
if (webSocket != nullptr) {
|
||||
std::ostringstream msg;
|
||||
msg << "SEND:" << user << ":" << json.dump();
|
||||
webSocket->send(msg.str(), false);
|
||||
webSocket->send(json.dump(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user