diff --git a/server/baseserv.cpp b/server/baseserv.cpp index e12a2d90c..2d4718ffb 100755 --- a/server/baseserv.cpp +++ b/server/baseserv.cpp @@ -459,24 +459,34 @@ void TBaseServerApp::ProcessCommand(wxString cmd, wxSocketBase& outs) outs << "PONG\n"; } -void TBaseServerApp::OnServerEvent(wxSocketEvent& WXUNUSED(e)) +void TBaseServerApp::OnServerEvent(wxSocketEvent& e) { // Accept new connection if there is one in the pending // connections queue, else exit. We use Accept(FALSE) for // non-blocking accept (although if we got here, there // should ALWAYS be a pending connection). - wxSocketBase* sock = m_server->Accept(false); - if (sock != NULL) + switch(e.GetSocketEvent()) { - sock->SetEventHandler(*this, SOCKET_ID); - sock->SetNotify(wxSOCKET_INPUT_FLAG | wxSOCKET_LOST_FLAG); - sock->Notify(true); - if (m_bLogVerbose) - WriteLog(_("Connection accepted.")); + case wxSOCKET_CONNECTION: + { + wxSocketBase* sock = m_server->Accept(false); + if (sock != NULL) + { + sock->SetEventHandler(*this, SOCKET_ID); + sock->SetNotify(wxSOCKET_INPUT_FLAG | wxSOCKET_LOST_FLAG); + sock->Notify(true); + if (m_bLogVerbose) + WriteLog(_("Connection accepted.")); + } + else + WriteLog(_("Connection REFUSED!")); + } + break; + default: + WriteLog(_("Unhandled server event!")); + break; } - else - WriteLog(_("Connection REFUSED!")); } struct TCommand : public wxObject @@ -516,6 +526,7 @@ void TBaseServerApp::OnSocketEvent(wxSocketEvent& e) case wxSOCKET_LOST: if (m_bLogVerbose) WriteLog("--- Socket lost."); + sock->Destroy(); break; default: break;