I am designing a server which is used in UDP communication using MFC. I have the following classes
- CMyDlialog - Take care of User interface
- CController - Act as an Mediator between all the classes
- CProtocolManager - Take care of Encoding/Decoding msgs (This is a static class)
- CConnectionManager - Take care of UDP connection, Sending, Receiving
I am creating an object of CConnectionManager as a member variable in CController and object of CController as member variable in CMyDialog.
When user type something and presses send, I am calling a method in CControler which will call a method in CProtocolManager to construct the packet and call the CConnectionManager method to send it.
When i receive some data, it is handled in a thread of CConnectionManager. There i am creating a local object of CController and call a method, which will pass the data to CProtocolManager to decode.
Now i want to inform the UI about the data, how should the CControler do it? i can post a message to the UI by making the main dialog handle global, is that a correct approach.
Also tell me whether this design is correct one.
Thanks in advance