mbx_RPC Tcl Command

NAME

mbx_RPC - Message command execution

SYNOPSIS

::dmh::mbx_RPC ?message ?reply_mailbox??


DESCRIPTION

This command is installed as part of the Distributed Message Hub from Hume Integration Software. The command is used to execute received message commands as Tcl code, and send back reply messages. The command also rearms the message system to handle the next message received on the same mailbox with the same handling code. The reply message is always a two element list; the return code from evaluating the message as code, and the usual Tcl execution result or the errorInfo stack trace.

If the arguments message and/or reply_mailbox are not supplied, their values are taken from the ::dmh namespace variables mbxmsg and mbxreply respectively. These variables are set up by the mbx command whenever a new message is received.

The example:

mbx whenmsg TCL_SERVER_RPC mbx_RPC

sets up the mailbox TCL_SERVER_RPC so that (1) whenever messages are sent to it, they are executed as Tcl commands and (2) a reply message is sent out if the sender specified a reply mailbox. The execution and reply message format are described under the mh_eval command.

Here is an example to show how an application can utilize mbx_RPC functionality in another application.

proc mbx_send {mailbox args} {
    global MB_XACT TIMEOUT 
    set reply [lindex [mbx_do_xact $mailbox $args $MB_XACT $TIMEOUT] 0]
    if { $REPLY == "TIMEOUT" } { error "TIMEOUT on mbx_send with $mailbox" }
    vset $reply {rc result}
    if { $rc == "0" } { return $result }
    error $result
    }

In the above example, the mbx_do_xact command dispatches events while waiting for a reply so the application stays responsive to the user interface or to other message exchanges if the reply is delayed. The mbx_do_xact command and similar commands are described on the manpage mbx_cmds.

The functionality of the mbx_RPC command matches the expected behavior of the inspect application which enables a remote Tcl Application to be inspected using the message system.

SEE ALSO

mbx, mbx_do_xact, mh_eval, send

AUTHOR

Ed Hume, Hume Integration Software

KEYWORDS

RPC, message system, dmh_inspect