- Callbacks are functions that are executed when certain events occur.
- Callbacks give you an object-oriented approach to the advanced features of TIBCO SmartSockets.
- TIBCO SmartSockets provides a number of different types of callbacks including: process, default process, subject, default subject, read, write, queue, server create, server destroy, encode, decode, and error.
- The two most common types of callbacks used in a TIBCO SmartSockets application are:
- process callbacks, which are invoked when a message of a given type is to be processed (default process callbacks are invoked if no process callback exists for the given type).
- subject callbacks, which are invoked when a message with a given destination is processed (default subject callbacks are invoked if no subject callback exists for the given destination)
- Subject callbacks are a superset of process callbacks. Within a subject callback, one can specify the message type it refers to.
- Process, subject, and their default callbacks are invoked by a call to TipcSrvMsgProcess.
- Server create callbacks are executed whenever an RTclient connects or reconnects to RTserver. Server destroy callbacks are executed when an RTclient loses its connection to RTserver.
- The convenience function TipcSrvMainLoop can be used to read and process incoming messages from RTserver. It replaces repeated calls to TipcSrvMsgNext, TipcSrvMsgProcess, and TipcMsgDestroy.
- TipcMsgSetNumFields can be used to reset the data part of a message. This is useful if you want to re-use the message.
- In situations where there are no TIBCO SmartSockets standard message types to meet your requirements, you can create user-defined message types.
- User-defined message types are created with a call to TipcMtCreate. This takes three arguments:
- a name, which is an identifier
- a unique number (greater than zero)
- a grammar, which defines what the data part of the message looks like
- A user-defined message type is assigned to a logging category by calling TipcSrvLogAddMt.
- A user-defined message type must be defined consistently, with TipcMtCreate, in all programs that use the message type. Once defined, it is treated no differently from a TIBCO SmartSockets standard message type.