Commit 7facffcf authored by zhanglix's avatar zhanglix Committed by Alex Hultman

fix a bug about multiple errors emitted for one connection (#652)

* fix bug about multiple error emited for one connection which make resource management of userDate difficult.

* Minor style fixes
parent dbb6719b
......@@ -114,6 +114,7 @@ void Hub::connect(std::string uri, void *user, std::map<std::string, std::string
secure = true;
} else if (protocol != "ws") {
eh->errorHandler(user);
return;
}
if (portStr.length()) {
......
......@@ -241,6 +241,15 @@ void testConnections() {
case 10:
std::cout << "Client emitted error on poll error" << std::endl;
break;
case 11:
static int protocolErrorCount = 0;
protocolErrorCount++;
std::cout << "Client emitted error on invalid protocol" << std::endl;
if (protocolErrorCount > 1) {
std::cout << "FAILURE: " << protocolErrorCount << " errors emitted for one connection!" << std::endl;
exit(-1);
}
break;
default:
std::cout << "FAILURE: " << user << " should not emit error!" << std::endl;
exit(-1);
......@@ -268,6 +277,7 @@ void testConnections() {
});
h.connect("invalid URI", (void *) 1);
h.connect("invalid://validButUnknown.yolo", (void *) 11);
h.connect("ws://validButUnknown.yolo", (void *) 2);
h.connect("ws://echo.websocket.org", (void *) 3, {}, 10);
h.connect("ws://echo.websocket.org", (void *) 8);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment