Galaxy Communicator Documentation:

MITRE Utilities: Brokering Tools

License / Documentation home / Help and feedback

MITRE offers a utility which bundles up some of the brokering information and slightly simplifies setting up a brokering connection. This utility involves three steps: defining type handlers for the broker, adding outgoing broker support, and adding incoming broker support.

The brokering example contains servers which illustrate this technique in addition to the technique support directly by the MIT API. This tool is completely compatible with the MIT API; it's possible to use the MITRE tools on one end of the connection and the MIT API on the other, and the MITRE tool works without the timed task loop in the same way as the MIT API does.

See the page on compiling and accessing these utilities.


Defining type handlers

A type handler accepts the broker structure, the data, and the data length as arguments:

typedef void (*MGal_BrokerDTHandler)(GalIO_BrokerStruct *broker_struct, void *data, int n_samples)

These type handlers should be registered in _GalSS_init_server:

void *_GalSS_init_server(GalIO_ServerStruct *s, int argc, char **argv)
{
  MGal_AddBrokerDTHandler(GAL_STRING, (void *) AUDIO_SERVER_NEW_UTT,
                          audio_in_new_utt);
  MGal_AddBrokerDTHandler(GAL_STRING, (void *) AUDIO_SERVER_SAMPLES_DONE,
                          audio_in_done);
  MGal_AddBrokerDTHandler(GAL_STRING, (void *) AUDIO_SERVER_SAMPLES_ABORT,
                          audio_in_abort);
  MGal_AddBrokerDTHandler(GAL_INT_16, (void *) NULL,
                          audio_in_int16_data);
  return (void *) NULL;
}
void MGal_AddBrokerDTHandler(Gal_ObjectType dt, void *val, MGal_BrokerDTHandler h)
The dt is an integer data type. The val is what the data needs to match (currently, this is only implemented for strings). The handler h is a callback function which will perform the appropriate actions for this type and match value.


Adding outgoing broker support

In the usual case, the programmer needs to populate the frame with the appropriate broker information, much of which is predictable. The MITRE utility handles this case.

GalIO_BrokerStruct *MGal_AddOutgoingBrokering(GalIO_CommStruct *gcomm, Gal_Frame fr, int poll_ms, int timeout_ms)
The arguments for this function are identical to those of GalIO_BrokerDataOutInit. In addition, this function computes the :call_id and records the appropriate host and port in the keys :broker_host and :broker_port.


Adding incoming broker support

GalIO_BrokerStruct *MGal_AddIncomingBrokering(Gal_Frame fr, int poll_ms, void *caller_data, int activate)
The fr and poll_ms arguments are identical to those of GalIO_BrokerDataInInit; the caller_data argument corresponds to the refptr argument there. In addition, this function accesses the host and port and establishes the dispatch function for selecting among the type handlers. If activate is nonzero, GalIO_SetBrokerActive will be called on the broker structure.
 
 

License / Documentation home / Help and feedback
Last updated September 20, 2000