The NexusDB Messaging package includes components to allow NexusDB clients to send
messages between themselves. Clients can set-up to receive all messages or
only messages designated for themselves. When messages are received, they are
immediately stored in a queue by the plugin and then handled by the client
application through either registered message handlers or a default event.
When clients want to participate in message, they register themselves with a server
by call RegisterClient with a description of themselves and if they want to be in
Promiscuous Mode, if they want to receive all messages. This mode is helpful for
debug purchases. Messages can be sent to all registered clients or to one specific
client.
When clients are finished communicating, or logging off, they should call the
function RemoveClient. At any time a client can call GetMessagingClients to
get a list of registered clients.
Another use of this component is to allow the server to notify clients of database,
table, or record changes using the TnxSimpleMonitor component and calling the
TpsnxServerMessagingPlugin.Broadcast methods when monitored events are fired.
Create a package project and add the 3 messaging units. Install this new project in your IDE.
On the server side, you need to setup two new components. Open up the NxServer
project and the form dmServer. Drop a TpsnxServerMessagingPlugin and a
TpsnxMessagingPluginCmdHandler on the form and wire up the properties. Important
properties for the MessagingPluginCmdHandler are CommandHandler and PluginEngine.
Make sure to set the EventLog property for both components.
On the client side, create a new project and add Transport, Session, and a SimpleCommandHandler components and wire them up. Then add a RemoteMessagingCmdHandler and a RemoteMessagingPlugin.
For the RemoteMessagingCmdHandler, set the CommandHandler and PluginEngine properties.
For the RemoteMessagingPlugin, set the Session property. On the Transport, change CallbackThreadCount from 0 to the number of simultaneous messages your system is expected to handle.
See the sample application for more details and examples of how to use send and receive messages. Sending text messages is easy by using the BroadcastTextMessage( aText: String ) method and then on the receiving side, using the RemoteMessagingPlugin's Event Handler to process the received message and "crack" the message using the ExtractTextMessage.
Bug reports, comments, and suggestions for improvements are welcome. Send
to nexusdb.public.support.thirdparty
Attachment | Size |
---|---|
Messaging Plugin.zip | 16.23 KB |