Back to Notification Service Examples Page Back

Notification Service Example: Mail

Description

This example shows the use of the Notification Service configured with a Push Supplier object connected to an event channel that sends events and a Pull Consumer object connected to the same event channel that receives events. The consumer-side proxy has a filter applied that only allows events destined to be received by the given Consumer to be delivered.

Synopsis

This example includes a client/server program that allows the creation of mailbox accounts identified by a given user name. Users can then login to given mailbox accounts to send and/or receive text-messages to/from other mailbox accounts.

Design

The example uses a single event channel and the following classes:

Other files used by this example include: Mail.hh, Mail.cpp, PullConsumer.hh, and PullSupplier.hh.

When the mailbox is launched, the initialisation process will use an existing Notification Service event channel with id 0 (zero) if one is available, otherwise it will create a new event channel.

The following commands control the mailbox example:

How to Build This Example

UNIX

These instructions are based on the Solaris gcc3.2 compiler makefiles.

  1. Ensure that the following environment variables are set:
  2. Ensure that your environment is set up for your compiler and linker. For example, for gcc3.2:

    PATH=/usr/local/gcc-3.2/bin:/usr/ccs/bin:$PATH; export PATH

    LD_LIBRARY_PATH=/usr/local/gcc-3.2/lib:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH

  3. Make a local copy of the <TAO install dir>/examples directory.
  4. Change to the <Local Copy>/cc directory.
  5. If you have not done so already, enter the make command to run the makefile. This will compile all of the OpenFusion examples.

Windows NT

  1. Set the environmental property TAO_ROOT=<TAO install dir>, where <TAO install dir> is the location into which you have installed TAO.
  2. Make a local copy of the <TAO install dir>\examples directory.
  3. Change to the <Local Copy>\cc\Common directory.
  4. A global example Microsoft Visual C++ project has been provided. This is called <Local Copy>\cc\cc.dsw. Double-click on the project file to load it into Microsoft Visual C++. When loaded, change the Common project from debug mode to release mode using the Build | SetActive Configuration option.
  5. Build the Common files.
  6. Build the NotificationMailExample files.
  7. Build the Mail files.

How to Run This Example

  1. Windows NT: Open a command prompt window. Ensure that the path contains:

    <TAO install dir>\lib;<Local Copy>\cc\bin

    UNIX: Ensure that the environment variable LD_LIBRARY_PATH includes the path to where the common files and the video files were compiled:

    LD_LIBRARY_PATH=<Local Copy>/cc/Common:<Local Copy>/cc/Notification/mail:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH

  2. Ensure that the Notification Service is running. In order to run the OpenFusion Notification Service you must first install the OpenFusion TCS - JacORB with OpenFusion CORBA Services distribution. This can be obtained from the downloads page by following the OpenFusion CORBA Products software link.

  3. Start two mail clients and servers in separate windows:

    Windows NT:

    mail -ORBInitRef NotificationService=file://<OF_INSTALL_DIR>/domains/OpenFusion/localhost/NotificationService/NotificationSingleton/NotificationSingleton.ior

    This will reply with the prompt ADMIN>.

    UNIX: Change to the <local copy>/cc/Notification/mail directory.

    ./mail -ORBInitRef NotificationService=file://<OF_INSTALL_DIR>/domains/OpenFusion/localhost/NotificationService/NotificationSingleton/NotificationSingleton.ior

    This will reply with the prompt ADMIN>

  4. Create a mailbox with the command:
    create mailbox1
  5. In the other process, window create a mailbox with the command:
    create mailbox2
  6. Login to each respective mailbox using the commands:
    login mailbox1

    and

    login mailbox2

    The command-line prompt will change to indicate the name of the logged-in account.

  7. When logged in to mailbox1, send a text message to mailbox2 using the command:
    send mailbox2 hello from mailbox1
  8. From the mailbox2 session, use the command:
    receive

    This should pull events from the Notification Service event channel and receive the text message sent from mailbox1.


PrismTech TOP
Top