We have a requirement to notify different clients (exe/processes, windows/MFC based UI) when certain values change in the system.
These values are stored in a file (which cannot be changed), and a server process shall poll these files for change in value and notify the clients whenever any change occurs. This notification shall happen via post message. The server would have stored the updated value in shared memory before notifying the clients. This values is either a long value or a string value of 250 uni code characters .
The flow shall be:
1> The server (notifier/publisher) would start on system start up. This server shall have a dummy window created (hidden) to receive post message notifications from clients.
2> The clients when launched or started shall subscribe/register themselves with the server using post message.
3> The clients shall find the server window name (using find window) and call post message on the server HWND to pass its own HWND as and its interested event ID as input value. (using WPARAM and LPARAM parameters of post message)
4> The server shall store the interested client's HWND and corresponding events in its memory in a map.
5> The server shall have a timer thread running for polling the file for any changes for sending notifications.
6> When value is changed, the server does a post message for particular events to interested clients using their HWND stored in their memory.
7> The client processes the post message from server and then decide to read the shared memory (based on name) to get the updated value to be displayed in its UI.
8> When client goes down, it shall unsubscribe itself with the server.
There might be max 4-6 clients at any point in time currently, its a windows machine and all clients shall be on the same machine.
I do understand that HWND value is only unique for a desktop, if there are multiple desktops, the HWND value need not be unique.
Also window's name need not be unique, hence find window done by the clients might get a different/duplicated window.
Also the notification from server to all the clients shall be sequential since there is no option of multi casting in this case. However post message in itself is asynchronous unlike send message which is blocking.
I would like to know the experts advice on using this approach and if there are any major concerns with this approach that they would like to highlight.
Thanks and regards,