 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Chris Guest
|
Posted: Sun Mar 07, 2004 10:34 pm Post subject: lib |
|
|
I wrote a lib for a p2p network that implements the protocol and queue
handling, etc. works fine.
The main class in the library is called Client and contains (among many
others) a run() method, which
does queue processing and runs for ever. When an inbound message is
received a switch is used to call an approriate processXYZMsg
function.
I now want to create a gui and console front ends for it and am trying
to figure out the code design.
I had originally planned (badly) that each gui would be derived from
Client, and therefore
be able to override eg processLoginReplyMsg() with their own methods.
As the run() method of Client blocks this idea sucks and is embarassing :)
I now think i should really have 2 threads, one for the Client and one
for the ui.
My question is this. As i can't override the processXYZ functions how
should i handle interaction between the Client lib and the gui?
One though i had was to pass function pointers as arguments to the Client
eg client.setProcessLoginReplyMsgFunction(some_callback_function);
Although in reality i would probably pass in some sort of map containing
all the function pointers in to the constructor of Client.
Any advice welcome on the best approach to this.
Thanks
Chris
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|