void CRealControlSocket::OnSocketEvent(wxSocketEvent &event) { if (!m_pBackend) return; if (event.GetId() != m_pBackend->GetId()) return; switch (event.GetSocketEvent()) { case wxSOCKET_CONNECTION: m_onConnectCalled = true; OnConnect(); break; case wxSOCKET_INPUT: if (!m_onConnectCalled) { m_onConnectCalled = true; OnConnect(); } OnReceive(); break; case wxSOCKET_OUTPUT: OnSend(); break; case wxSOCKET_LOST: OnClose(); break; } }
void CTlsSocket::OnSocketEvent(wxSocketEvent& event) { wxASSERT(m_pSocket); if (!m_session) return; if (event.GetId() != m_pSocketBackend->GetId()) return; switch (event.GetSocketEvent()) { case wxSOCKET_INPUT: OnRead(); break; case wxSOCKET_OUTPUT: OnSend(); break; case wxSOCKET_LOST: { m_canCheckCloseSocket = true; char tmp[100]; m_pSocketBackend->Peek(&tmp, 100); if (!m_pSocketBackend->Error()) { int lastCount = m_pSocketBackend->LastCount(); if (lastCount) m_pOwner->LogMessage(Debug_Verbose, _T("CTlsSocket::OnSocketEvent(): pending data, postponing wxSOCKET_LOST")); else m_socketClosed = true; OnRead(); if (lastCount) return; } m_pOwner->LogMessage(Debug_Info, _T("CTlsSocket::OnSocketEvent(): wxSOCKET_LOST received")); //Uninit(); wxSocketEvent evt(GetId()); evt.m_event = wxSOCKET_LOST; wxPostEvent(m_pEvtHandler, evt); } break; default: break; } }