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.
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.
The example uses a single event channel and the following classes:
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:
create <username>
creates a user account by
deriving a default admin object from the event channel and a ProxyPullSupplier
object from this. The ProxyPullSupplier then has a filter applied to it to
identify the user owning the mailbox. The proxy's IOR is then stored in a file
with a name derived from the given
user name.
login <username>
opens the appropriate mailbox
file, retrieves the ProxyPullSupplier IOR and connects to the event-channel.
send <username> <message>
applies the
user name
information to the filterable body of a Notification Service structured event and
pushes the
event
containing the given message to the connected event-channel.
receive
pulls events from the event-channel.
exit
will exit the program.
These instructions are based on the Solaris gcc3.2 compiler makefiles.
ACE_ROOT=<TAO install dir>; export ACE_ROOT
TAO_ROOT=<TAO install dir>; export TAO_ROOT
SHLIB_PATH=$TAO_ROOT/lib; export SHLIB_PATH
LD_LIBRARY_PATH=$TAO_ROOT/lib:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH
PATH=$PATH:$TAO_ROOT/bin; export PATH
INSLIB=$TAO_ROOT/lib; export INSLIB
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
<TAO install dir>/examples/cc
directory.
make
command to run the makefile. This will compile all of the OpenFusion examples.
TAO_ROOT=<TAO install dir>
,
where <TAO install dir>
is the location into which you have
installed TAO.
<TAO install dir>\examples\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 | Set Active Configuration menu option.
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=<TAO install dir>/examples/cc/Common:<TAO install dir>/examples/cc/Notification/mail:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH
Windows NT: Start a DOS window. Ensure that your path contains:
<TAO
install dir>\bin;<TAO install dir>\examples\cc\bin
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.
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 <TAO install dir>/examples/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>
create mailbox1
create mailbox2
login mailbox1
and
login mailbox2
The command-line prompt will change to indicate the name of the logged-in account.
send mailbox2 hello from mailbox1
receive
This should pull events from the Notification Service event channel and receive the text message sent from mailbox1.