Isolated wxEvtHandler

Сергей Коныгин <[email protected]>
Newsgroups gmane.comp.lib.wxwindows.general
Message-ID <[email protected]>
Hi!

I'm working on creating a simple library for my server applications.  The 
simplified code is shown below. The main application creates a Server 
object.  The server creates many ServerSession objects that handle 
connections. 
Since this is a library, I want network events to be handled by these 
objects. But it doesn't work for me. Should I somehow link my wxEvtHandlers to 
the main wxAppConsole (SetNextHandler and SetPreviousHandler)?

class Server : public wxEvtHandler
{
bool StartServer()
{
... 
mpServer = new wxSocketServer( addr );
mpServer->SetEventHandler( *this, SERVER_ID );
mpServer->SetNotify( wxSOCKET_CONNECTION_FLAG|wxSOCKET_LOST_FLAG );
mpServer->Notify( true );
...
}

void OnServerEvent( wxSocketEvent& event )
{
...
if( event.GetSocketEvent() == wxSOCKET_CONNECTION )
{
wxSocketBase* pSocket = mpServer->Accept( false );
ServerSession* pSession = new ServerSession( pSocket );
}
...
}
};

class ServerSession : public wxEvtHandler
{
ServerSession( wxSocketBase* pSocket )
{
...
pSocket->SetEventHandler( *this, SOCKET_ID );
pSocket->SetNotify( wxSOCKET_INPUT_FLAG );
pSocket->Notify( true );
...
}
};

-- 
Please read https://www.wxwidgets.org/support/mlhowto.htm before posting.
--- 
You received this message because you are subscribed to the Google Groups "wx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/wx-users/5d4771e4-8997-46d4-ad05-26bbabdb2a0an%40googlegroups.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.