From ff1795cccd6ffa13a07264fccc88cdc17cccfdb2 Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 3 Feb 2010 08:38:49 +0000 Subject: [PATCH] Patch level : Files correlati : Ricompilazione Demo : [ ] Commento : git-svn-id: svn://10.65.10.50/trunk@20047 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- server/baseserv.cpp | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) 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;