Server and add-in share some common communications code, which is stored in the Comms sub-directory of MtFeed. The usage pattern of the module is typical of comms client/server applications. However, the code is not as robust as would be expected of such a module in the real world, and it is provided for demonstration purposes only.
The important thing from the client point of view is that all requests to the server should be made from the same thread that creates the channel. These requests include the following functions:
Function | Description |
---|---|
mtcStartClient | Initialize the channel |
mtcStopClient | Terminate the channel |
mtcAdvise | Request ongoing information about a topic |
mtcUnadvise | Terminate ongoing information about a topic |
mtcSendData | Send information about a topic to the server |
When data arrives asynchronously from the server, the client comms module invokes a call-back function in a background thread, owned and controlled by the comms module. This is never the same thread as the one which opened the channel.
It is the responsibility of the client application to pass the data packet from the background thread to the thread (usually the main thread) that will process it.