From 7996bd5c36cbbe9b6aa58dc52abdd63191a5c234 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Sun, 5 Jan 2020 14:49:37 +0900 Subject: [PATCH] Client on connect fail now returns FAIL_CONNECT Previously, returned event was DISCONNECT. FAIL_CONNECT is a new event enum value. --- src/UDPConnection.cpp | 9 +++++++-- src/UDPConnection.h | 1 + src/test/UDPC_NetworkTest.c | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/UDPConnection.cpp b/src/UDPConnection.cpp index 15ec54f..73a8fe8 100644 --- a/src/UDPConnection.cpp +++ b/src/UDPConnection.cpp @@ -478,8 +478,13 @@ void UDPC::Context::update_impl() { idMap.erase(cIter->second.id); } if(isReceivingEvents.load()) { - externalEvents.push(UDPC_Event{ - UDPC_ET_DISCONNECTED, *iter, false}); + if(flags.test(1) && !cIter->second.flags.test(4)) { + externalEvents.push(UDPC_Event{ + UDPC_ET_FAIL_CONNECT, *iter, false}); + } else { + externalEvents.push(UDPC_Event{ + UDPC_ET_DISCONNECTED, *iter, false}); + } } conMap.erase(cIter); diff --git a/src/UDPConnection.h b/src/UDPConnection.h index 290365d..f516dd7 100644 --- a/src/UDPConnection.h +++ b/src/UDPConnection.h @@ -195,6 +195,7 @@ typedef enum { UDPC_ET_REQUEST_DISCONNECT, UDPC_ET_CONNECTED, UDPC_ET_DISCONNECTED, + UDPC_ET_FAIL_CONNECT, UDPC_ET_GOOD_MODE, UDPC_ET_BAD_MODE } UDPC_EventType; diff --git a/src/test/UDPC_NetworkTest.c b/src/test/UDPC_NetworkTest.c index 0a64070..3f072cc 100644 --- a/src/test/UDPC_NetworkTest.c +++ b/src/test/UDPC_NetworkTest.c @@ -324,6 +324,9 @@ int main(int argc, char **argv) { case UDPC_ET_DISCONNECTED: typeString = "DISCONNECTED"; break; + case UDPC_ET_FAIL_CONNECT: + typeString = "FAIL_CONNECT"; + break; case UDPC_ET_GOOD_MODE: typeString = "GOOD_MODE"; break;