| 1 |
#include "csNetworkThread.h" |
| 2 |
#include "csConfig.h" |
| 3 |
#include <SocketAPI/clSocketServer.h> |
| 4 |
#include <file_logger.h> |
| 5 |
|
| 6 |
wxDEFINE_EVENT(wxEVT_SOCKET_CONNECTION_READY, clCommandEvent); |
| 7 |
wxDEFINE_EVENT(wxEVT_SOCKET_SERVER_ERROR, clCommandEvent); |
| 8 |
|
| 9 |
csNetworkThread::csNetworkThread(wxEvtHandler* manager, const csConfig& config) |
| 10 |
: csJoinableThread(manager) |
| 11 |
, m_config(config) |
| 12 |
{ |
| 13 |
} |
| 14 |
|
| 15 |
csNetworkThread::~csNetworkThread() {} |
| 16 |
|
| 17 |
void* csNetworkThread::Entry() |
| 18 |
{ |
| 19 |
// FileLoggerNameRegistrar logName("Network"); |
| 20 |
// clSocketServer server; |
| 21 |
// clDEBUG() << "Network thread is starting..."; |
| 22 |
// |
| 23 |
// try { |
| 24 |
// server.Start(m_config.GetConnectionString()); |
| 25 |
//} catch(clSocketException& e) { |
| 26 |
// clERROR() << "Network thread failed to start on '" << m_config.GetConnectionString() << "'." << e.what(); |
| 27 |
// clCommandEvent errorEvent(wxEVT_SOCKET_SERVER_ERROR); |
| 28 |
// m_manager->AddPendingEvent(errorEvent); |
| 29 |
// return NULL; |
| 30 |
//} |
| 31 |
// |
| 32 |
// clDEBUG() << "Waiting for new connection..."; |
| 33 |
// while(true) { |
| 34 |
// if(TestDestroy()) { break; } |
| 35 |
// clSocketBasePtr_t conn = server.WaitForNewConnectionRaw(1); |
| 36 |
// if(conn) { |
| 37 |
// clDEBUG() << "Received new connection"; |
| 38 |
// // Call reset with a dummy Deleter |
| 39 |
// // so we can get the raw pointer without destroying it |
| 40 |
// clCommandEvent newConnEvent(wxEVT_SOCKET_CONNECTION_READY); |
| 41 |
// newConnEvent.SetClientData(static_cast<void*>(conn)); |
| 42 |
// m_manager->AddPendingEvent(newConnEvent); |
| 43 |
// } |
| 44 |
//} |
| 45 |
// clDEBUG() << "Network thread is going down"; |
| 46 |
return NULL; |
| 47 |
} |