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

View File

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