remember the events we were notified about in OnRequest() (not used yet but necessary for upcoming changes)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57565 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-12-26 14:33:52 +00:00
parent 78014c105d
commit 5c1193e090
2 changed files with 35 additions and 24 deletions

View File

@@ -101,8 +101,6 @@ enum wxSocketType
class WXDLLIMPEXP_NET wxSocketBase : public wxObject
{
DECLARE_CLASS(wxSocketBase)
public:
// Public interface
@@ -251,11 +249,13 @@ private:
void *m_clientData; // client data for events
bool m_notify; // notify events to users?
wxSocketEventFlags m_eventmask; // which events to notify?
wxSocketEventFlags m_eventsgot; // collects events received in OnRequest()
// the initialization count, GSocket is initialized if > 0
static size_t m_countInit;
DECLARE_NO_COPY_CLASS(wxSocketBase)
DECLARE_CLASS(wxSocketBase)
};

View File

@@ -612,7 +612,8 @@ void wxSocketBase::Init()
m_handler = NULL;
m_clientData = NULL;
m_notify = false;
m_eventmask = 0;
m_eventmask =
m_eventsgot = 0;
if ( !IsInitialized() )
{
@@ -1488,24 +1489,35 @@ void wxSocketBase::OnRequest(wxSocketNotify notification)
return;
}
// Schedule the event
wxSocketEventFlags flag = 0;
wxUnusedVar(flag);
switch ( notification )
{
case wxSOCKET_INPUT: flag = wxSOCKET_INPUT_FLAG; break;
case wxSOCKET_OUTPUT: flag = wxSOCKET_OUTPUT_FLAG; break;
case wxSOCKET_CONNECTION: flag = wxSOCKET_CONNECTION_FLAG; break;
case wxSOCKET_LOST: flag = wxSOCKET_LOST_FLAG; break;
case wxSOCKET_INPUT:
flag = wxSOCKET_INPUT_FLAG;
break;
case wxSOCKET_OUTPUT:
flag = wxSOCKET_OUTPUT_FLAG;
break;
case wxSOCKET_CONNECTION:
flag = wxSOCKET_CONNECTION_FLAG;
break;
case wxSOCKET_LOST:
flag = wxSOCKET_LOST_FLAG;
break;
default:
wxLogWarning(_("wxSocket: unknown event!."));
return;
wxFAIL_MSG( "unknown wxSocket notification" );
}
if (((m_eventmask & flag) == flag) && m_notify)
{
if (m_handler)
// remember the events which were generated for this socket, we're going to
// use this in DoWait()
m_eventsgot |= flag;
// send the wx event if enabled and we're interested in it
if ( m_notify && (m_eventmask & flag) && m_handler )
{
wxSocketEvent event(m_id);
event.m_event = notification;
@@ -1515,7 +1527,6 @@ void wxSocketBase::OnRequest(wxSocketNotify notification)
m_handler->AddPendingEvent(event);
}
}
}
void wxSocketBase::Notify(bool notify)
{