diff --git a/CMakeLists.txt b/CMakeLists.txt index ae3e2819e..853a0ee6f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -352,7 +352,7 @@ IF(EQEMU_BUILD_SERVER) ADD_SUBDIRECTORY(world) ADD_SUBDIRECTORY(zone) ADD_SUBDIRECTORY(ucs) - ADD_SUBDIRECTORY(queryserv) + #ADD_SUBDIRECTORY(queryserv) ADD_SUBDIRECTORY(eqlaunch) ENDIF(EQEMU_BUILD_SERVER) IF(EQEMU_BUILD_LOGIN) diff --git a/common/net/tcp_server.cpp b/common/net/tcp_server.cpp index dc2677b1e..16953be9c 100644 --- a/common/net/tcp_server.cpp +++ b/common/net/tcp_server.cpp @@ -27,16 +27,18 @@ void EQ::Net::TCPServer::Listen(int port, bool ipv6, std::functiondata = this; - uv_tcp_bind(m_socket, &iaddr, 0); uv_listen((uv_stream_t*)m_socket, 128, [](uv_stream_t* server, int status) { if (status < 0) { diff --git a/ucs/ucs.cpp b/ucs/ucs.cpp index 8e067b12a..22cde0754 100644 --- a/ucs/ucs.cpp +++ b/ucs/ucs.cpp @@ -33,6 +33,8 @@ #include #include +#include "../common/net/tcp_server.h" + ChatChannelList *ChannelList; Clientlist *g_Clientlist; EQEmuLogSys Log; @@ -142,6 +144,32 @@ int main() { worldserver->Connect(); + EQ::Net::TCPServer server; + std::vector> connections; + server.Listen(5999, true, [&](std::shared_ptr connection) { + Log.OutF(Logs::General, Logs::Debug, "New connection found."); + connections.push_back(connection); + + connection->OnRead([](EQ::Net::TCPConnection *connection, const unsigned char *data, size_t length) { + EQ::Net::ReadOnlyPacket p((void*)data, length); + Log.OutF(Logs::General, Logs::Debug, "{0}", p.ToString()); + }); + + connection->OnDisconnect([&](EQ::Net::TCPConnection *connection) { + auto iter = connections.begin(); + while (iter != connections.end()) { + if ((*iter).get() == connection) { + Log.OutF(Logs::General, Logs::Debug, "Removing connection"); + connections.erase(iter); + return; + } + iter++; + } + }); + + connection->Start(); + }); + while(RunLoops) { Timer::SetCurrentTime();