Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents
maxLevel4

Overview

The Virtual Human Messaging library (VHMSG) defines a protocol and provides an API wrapper around ActiveMQ. It's intended to provide an easy solution for sending and receiving messages within the Virtual Human Architecture. It supports the following programming languages:

...

When creating new modules, be sure to implement the messaging protocol as defined here. This ensures components are aware of each other's existence and that they behave correctly.

Users

How to change the ActiveMQ server or scope

You can change these by creating VHMSG_SERVER and VHMSG_SCOPE environment variables. For Windows XP, right click on My Computer, select Properties, go to the Advanced tab in the new window, and select Environment Variables.

How can I see to which ActiveMQ server and scope I am connected?

You can see this in the top right corner of the Logger, or in the Launcher after going to the Advanced menu and clicking on Show Information, at the bottom.

Developers

How do I implement and use VHMSG in C++

Our C++ implementation is built on top of the C++ ActiveMQ libraries called CMS (http://activemq.apache.org/cms/). Headers and libraries are provided for Visual Studio 2005 and 2008. VS2008 is the currently maintained version.

...

A sample using this implementation is included in \lib\vhmsg\samples\elbench\cpp\elbench.cpp. A condensed version of this sample is shown to give you an idea of what's required:

Code Block

#include "vhmsg-tt.h"

void tt_client_callback( char * op, char * args )
{
    printf( "received - '%s %s'\n", op, args );
}

int main()
{
    // set up our callback for receiving messages
    vhmsg::ttu_set_client_callback( tt_client_callback );

    // connect to the server
    err = vhmsg::ttu_open();
    if ( err == TTU_ERROR )
    {
        printf( "Connection error!\n" );
        return -1;
    }

    // register which message we’re interested in receiving
    err = vhmsg::ttu_register( "elbench" );

    // send a message
    vhmsg::ttu_notify2( "elbench", “Hello World” );

    // poll to receive messages.  callback function is called for each message received
    while ( !_kbhit() )
    {
        err = vhmsg::ttu_poll();
        if( err == TTU_ERROR )
        {
            printf( "ttu_poll ERR\n" );
        }
    }

    // cleanup
    vhmsg::ttu_close();
}

...

Be sure to implement the messaging protocol as defined here.

How do I implement and use VHMSG in C#

Our C# implementation is built on top of the C# ActiveMQ libraries called NMS (http://activemq.apache.org/nms/).

A elbench sample is included in \lib\vhmsg\samples\elbench\cs\elbench.cs. A condensed version of the sample is shown to give you an idea of what's required:

Code Block

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
   elbenchcs e = new elbenchcs();
   e.Run();
}


public void Run()
{
   VHMsg.Client vhmsg;
   using ( vhmsg = new VHMsg.Client() )
   {
      vhmsg.OpenConnection();

      vhmsg.MessageEvent += new VHMsg.Client.MessageEventHandler( MessageAction );

      vhmsg.SubscribeMessage( "elbench" );

      vhmsg.SendMessage( "elbench Hello World" );


      // Run your app, messages are received via a different thread
   }
}


private void MessageAction( object sender, VHMsg.Message args )
{
   // Note: Messages are received on a different thread.  Please lock accordingly, and pay extra careful while calling UI commands.

   //Ict.ElvinUtility eu = (Ict.ElvinUtility)sender;
   //Console.WriteLine( "Received Message '" + args.toString() + "'" );
}

...

Be sure to implement the messaging protocol as defined here.

How do I implement and use VHMSG in Java

Our Java implementation is built on top of the Java ActiveMQ libraries (http://activemq.apache.org).

An elbench sample is included in \lib\vhmsg\samples\elbench\java\src\elbench.java. A condensed version of the sample is shown to give you an idea of what's required:

Code Block


import edu.usc.ict.vhmsg.*;


public class elbench implements MessageListener
{
   public static VHMsg vhmsg;


   public elbench()
   {
      vhmsg = new VHMsg();

      boolean ret = vhmsg.openConnection();
      if ( !ret )
      {
         System.out.println( "Connection error!" ); 
         return;
      }

      vhmsg.enableImmediateMethod();
      vhmsg.addMessageListener( this );
      vhmsg.subscribeMessage( "elbench" );

      vhmsg.sendMessage( "elbench Hello World" );

      // Run your app, messages are received via a different thread
   }


   public void messageAction( MessageEvent e )
   {
      // Note: Messages are received on a different thread.
      //       Please lock accordingly, and pay extra careful while calling UI commands.

      //System.out.println( "Received Message '" + e.toString() + "'" );
   }


   public static void main( String[] args )
   {
      elbench elbenchObj = new elbench();
   }
}

...

Be sure to implement the messaging protocol as defined here.

Known Issues

FAQ

See Main FAQ for frequently asked questions regarding the installer. Please use the Google Groups emailing list for unlisted questions.