Skip to content
Alessandro Febretti edited this page Nov 12, 2015 · 12 revisions

Last revision: ver. 10.1 - 11 November 2015

Mission Control is one of the core components of omegalib. You can use Mission Control to connect multiple applications together or let external applications talk to omegalib applications. Mission Control provides a simple messaging protocol and C++, python and command-line interfaces to the protocol.

Although the Mission Control protocol can be used to transfer arbitrary data between applications, it is mostly used to exchange script commands that are executed by each application python interpreter.

NOTE: Only the C++ API lets users define custom mission control messages. The python and command line interfaces only allow for the exchange of script commands.

Enabling Mission Control

Omegalib applications using Mission Control can start in either client or server mode. Applications running in server mode also run a local client, so they can process messages locally in addition to acting as message routers for other clients. It is also possible to run a standalone server using the mcserver command in the omegalib distribution.

To setup mission control for an application, you can either edit the missionControl config section in the application or system configuration file. Or you can change settings using the --mc command line option.

Python Mission Control Interface

The Python Mission Control API is implemented in two classes: MissionControlClient and MissionControlServer. Refer to their documentation for more info on how to use them.

Interactive Shell Interface

Mission Control can be accessed easily from the python shell when running applications in interactive mode (i.e. using the -i command line option). When applications are in interactive mode and are connected to other applications, you can send commands to other clients directly from the python shell using the @ special quick command:

  • @? will list all connected clients
  • @[clientid] will connect the shell to the specified client. All commands you type after this will be forwarded to clientid. Note that clientid can also be a prefix: if you end it with a * character, all clients matching the prefix will receive the commands you type.
  • @* will forward your next commands to all connected clients
  • @ alone will return the interactive shell to local execution mode.

Example:

>@?                   <-- list clients
 client1
 client2
 otherclient
>@otherclient         <-- connect to otherclient
>x = 100              <-- this command executed on otherclient
>@client*             <-- connect to client1 and client2
>y = 16               <-- command executed on client1 and client2
>@                    <-- go back to local command execution

Command-line interface

The quick-and-dirty way is to use the mcsend executable that you can find in your copy of omegalib (in bin)

mcsend syntax is like this

> mcsend <python-command> [-h host][-p port]

for instance,

> mcsend "getSceneManager().setBackgroundColor(Color('white'))" -h machine.mydomain.com

will set a white background to an application running on machine.mydomain.com.

For basic message sending, if you can invoke mcsend from your application that's pretty much all you need.

Another option is to connect directly to the omegalib application with a TCP socket, sending a message in the same format used by mcsend. This would allow you to keep a connection open and send multiple messages and or / get answers back.

Protocol Format

The protocol is pretty basic and is as follows:

  • 4 bytes - message header (interpreted as 4 ASCII characters)
  • 4 bytes - data length (converted to 32bit integer)
  • n bytes - data

For instance if you want to send a python command to an omegalib application, you would connect to that application on port 22500 (the default mission control port) and send a message like this:

  • [bytes 0-3] - "scmd" < tells the server this message contains an executable script command
  • [bytes 4-7] - command string length
  • [bytes 8-n] - command string as ASCII, not \0 terminated.

Mission Control: Example connection diagrams

Mission Control Example 1: Controlling an instance through a web interface or the command-line `mcsend` tool.

Mission Control Example 2: Peer-to-peer communication between two omegalib instances.

Mission Control Example 3: Multi-application collaboration and control using a standalone mission control server.

Clone this wiki locally