From ab642cc8d85af217d50dc6ca9f2f87ac844a4422 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Mon, 16 Jul 2018 19:04:25 -0300 Subject: [PATCH] Attempt to fix weird multi crash --- src/NetworkSyncManager.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/NetworkSyncManager.cpp b/src/NetworkSyncManager.cpp index ad1a232626..5215963979 100644 --- a/src/NetworkSyncManager.cpp +++ b/src/NetworkSyncManager.cpp @@ -420,9 +420,6 @@ bool ETTProtocol::Connect(NetworkSyncManager * n, unsigned short port, RString a n->isSMOnline = false; msgId = 0; error = false; - uWSh->onDisconnection([this, n](uWS::WebSocket *ws, int code, char *message, size_t length) { - this->ws = nullptr; - }); uWSh->onConnection([n, this, address](uWS::WebSocket *ws, uWS::HttpRequest req) { n->isSMOnline = true; this->ws = ws; @@ -430,17 +427,21 @@ bool ETTProtocol::Connect(NetworkSyncManager * n, unsigned short port, RString a }); uWSh->onError([this](void* ptr) { this->error = true; + this->ws = nullptr; }); uWSh->onHttpDisconnection([this](uWS::HttpSocket* ptr) { this->error = true; + this->ws = nullptr; }); - uWSh->onDisconnection([this](uWS::WebSocket *, int code, char *message, size_t length) { + uWSh->onDisconnection([this](uWS::WebSocket *, int code, char *message, size_t length) { this->error = true; this->errorMsg = string(message, length); + this->ws = nullptr; }); - uWSh->onDisconnection([this](uWS::WebSocket *, int code, char *message, size_t length) { + uWSh->onDisconnection([this](uWS::WebSocket *, int code, char *message, size_t length) { this->error = true; this->errorMsg = string(message, length); + this->ws = nullptr; }); uWSh->onMessage([this](uWS::WebSocket *ws, char *message, size_t length, uWS::OpCode opCode) { string msg(message, length);