MCPcopy Create free account
hub / github.com/NoMercy-ac/NoMercy / InitializeServerSocket

Method InitializeServerSocket

Source/Client/NM_Engine/ServerSocketMain.cpp:9–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7#include "ExceptionHandlers.h"
8
9bool CNetwork::InitializeServerSocket()
10{
11 m_pNetServer = std::make_shared<CNetworkServer>(m_NetService);
12 if (!IS_VALID_SMART_PTR(m_pNetServer))
13 {
14 NETWORK_LOG(LL_SYS, "m_pNetServer can NOT allocated! Last error: %u", g_winapiApiTable->GetLastError());
15 return false;
16 }
17
18 m_bIsInitialized = true;
19
20 try
21 {
22 m_pNetServer->Init();
23 m_pNetServer->Run();
24 m_pNetServer->Shutdown();
25 }
26 catch (std::exception& e)
27 {
28#ifdef _DEBUG
29 NETWORK_LOG(LL_ERR, "Exception handled: %s", e.what());
30#else
31 UNREFERENCED_PARAMETER(e);
32#endif
33 }
34 catch (DWORD dwNumber)
35 {
36#ifdef _DEBUG
37 NETWORK_LOG(LL_ERR, "Exception handled: %p", dwNumber);
38 CExceptionHandlers::OnExceptionThrowed(nullptr);
39#else
40 UNREFERENCED_PARAMETER(dwNumber);
41#endif
42 }
43 catch (...)
44 {
45#ifdef _DEBUG
46 NETWORK_LOG(LL_ERR, "Unhandled exception!");
47 CExceptionHandlers::OnExceptionThrowed(nullptr);
48#endif
49 }
50
51 m_pNetServer.reset();
52 return true;
53}

Callers 1

NetworkRoutineFunction · 0.80

Calls 4

ShutdownMethod · 0.80
resetMethod · 0.80
InitMethod · 0.45
RunMethod · 0.45

Tested by

no test coverage detected