Starts the server!
| 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() |
nothing calls this directly
no outgoing calls
no test coverage detected