MCPcopy Create free account
hub / github.com/OneLoneCoder/olcPixelGameEngine / Start

Method Start

extensions/olcPGEX_Network.h:817–840  ·  view source on GitHub ↗

Starts the server!

Source from the content-addressed store, hash-verified

815
816 // Starts the server!
817 bool Start()
818 {
819 try
820 {
821 // Issue a task to the asio context - This is important
822 // as it will prime the context with "work", and stop it
823 // from exiting immediately. Since this is a server, we
824 // want it primed ready to handle clients trying to
825 // connect.
826 WaitForClientConnection();
827
828 // Launch the asio context in its own thread
829 m_threadContext = std::thread([this]() { m_asioContext.run(); });
830 }
831 catch (std::exception& e)
832 {
833 // Something prohibited the server from listening
834 std::cerr << "[SERVER] Exception: " << e.what() << "\n";
835 return false;
836 }
837
838 std::cout << "[SERVER] Started!\n";
839 return true;
840 }
841
842 // Stops the server!
843 void Stop()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected