Chat Example


TOC

  1. Introduction
  2. How to compile
    1. On Unix
    2. On Windows/NT
  3. How to run
    1. On Unix
    2. On Windows/NT
  4. User Interface
  5. Software Design
  6. Changes

1. Introduction

Chat example uses the interaction class to send its messages to all the connected federates. Each message contains the name of the federate and its message.

User interface contains four action buttons:

Connect: joins the federation execution,
Mail: sends the message if the federate is joined the execution,
Disconnect: resigns from federation execution, and
Exit: terminates the program. If the federate did not resign yet, it also resigns from the federation execution.

The Main menu contains a name option that allows user to enter its name. This name is used as a federate name during the registration.

Chatter1.xml in $(OWRTI_HOME)/xml directory contains the federation definition. Federates use Message parameter of Chatter interaction class to send interactions. Federates subscribe the Message parameter to receive the other federates' interactions.

2. How to compile

JDK1.2.1 is used for compiling.

2.1. On Unix

  1. Makefile contains necessary compile parameters. It includes $(OWRTI_HOME)/mk/config.mk configuration file. This file contains variables for:

    1. Java installation directory (J_HOME),
    2. OWRTI installation directory (OWRTI_HOME), and
    3. JWORB installation directory (JWORB_HOME).

    These variables should be set to the proper directories.

  2. make

    compiles the codes.

2.2. On Windows/NT

  1. Makefile.win contains necessary compile parameters. It includes $(OWRTI_HOME)/mk/config.win configuration file. This file contains variables for:

    1. Java installation directory (J_HOME),
    2. OWRTI installation directory (OWRTI_HOME), and
    3. JWORB installation directory (JWORB_HOME).

    These variables should be set to the proper directories.

  2. nmake /f Makefile.win

    compiles the codes.

3. How to run

JDK1.2.1 is used for testing.

3.1. On Unix

  1. Makefile contains necessary compile parameters. It includes $(OWRTI_HOME)/mk/config.mk configuration file. This file contains variables for:

    1. Java installation directory (J_HOME),
    2. OWRTI installation directory (OWRTI_HOME), and
    3. JWORB installation directory (JWORB_HOME).

    These variables should be set to the proper directories.

  2. Chatter1.xml file is stored in $(OWRTI_HOME)/xml directory. This file should be placed in $(JWORB_HOME)/config directory since the JWORB actually starts up the OWRTI.

  3. kernel.srv file contains machine name and port number pairs. These pairs are used to find a running JWORB server. Therefore, you should add your running JWORB's machine name and port number information into this file. Assume that your JWORB is running on herman.arl.mil port number 3142, then kernel.srv should contain

    herman.arl.mil 3142
    osprey2.npac.syr.edu 4004

    During the runtime, system goes through the entries in order and uses the first JWORB that runs the OWRTI.

  4. runChat

    script starts up the GUI.

3.2. On Windows/NT

  1. Makefile.win contains necessary compile parameters. It includes $(OWRTI_HOME)/mk/config.win configuration file. This file contains variables for:

    1. Java installation directory (J_HOME),
    2. OWRTI installation directory (OWRTI_HOME), and
    3. JWORB installation directory (JWORB_HOME).

    These variables should be set to the proper directories.

  2. Chatter1.xml file is stored in $(OWRTI_HOME)/xml directory. This file should be placed in $(JWORB_HOME)/config directory since the JWORB actually starts up the OWRTI.

  3. kernel.srv file contains machine name and port number pairs. These pairs are used to find a running JWORB server. Therefore, you should add your running JWORB's machine name and port number information into this file. Assume that your JWORB is running on herman.arl.mil port number 3142, then kernel.srv should contain

    herman.arl.mil 3142
    osprey2.npac.syr.edu 4004

    During the runtime, system goes through the entries in order and uses the first JWORB that runs the OWRTI.

  4. runChat

    script starts up the GUI. (This is a .BAT file).

4. User Interface

Chat program requires that the user enters a name and joins the federation (by clicking Connect button). The user can see, send its messages (by using Mail button) or leaves the federation execution (by clicking Disconnect or Exit). A possible steps can be sumarized as follows:

  1. Select Name from Menu (Figure 2 and 3),
  2. Enter a name, this enables the Connect button (Figure 4),
  3. Click on Connect button to join the session (Figure 5),
  4. Message box is used to type in messages that the user wants to send.
  5. Click on Mail button to send the message (Figure 6).

Figure 1. The name is not given.

Figure 2. Menu presents two options: Name and Exit.

Figure 3. The name is entered within the pop-up window.

Figure 4. When the user enters a name, the user can connect the session.

Figure 5. After the connection is established, the user can mail his/her
message or disconnect from the session.

Figure 6. A snapshot of ongoing session.

5. Software Design

It included the following files:

ChatFedAmb.java: Federation Ambassador implementation for Chat.
ChatGUI.java: GUI and logic.
GetName.java: Gets the name.
mainChat.java: starts up the program.
Figure 7. UML diagram for the objects in the program.

ChatFedAmb.java is the Federation Ambassador implementation for RTI callbacks.

ChatGUI.java controls the users interaction with the RTI. It contains the following buttons:

  1. Connect
  2. Mail
  3. Disconnect
  4. Exit

and Menu with Name and Exit option.

GUI behaves as a finite state machine with 3 states:

A:Not Connected with no-name
B:Not Connected with name
C:Connected
D:Exit
     State Transitions:
        A --- (enter Name) ---->B
        B --- (click Connect) ---->C
        C --- (click Disconnect) ---->B
        C --- (click Mail) ---->C
        A --- (click Exit) ---->D
        B --- (click Exit) ---->D
        C --- (click Exit) ---->B,D
        A --- (choose Exit in Menu) ---->D
        B --- (choose Exit in Menu) ---->D
        C --- (choose Exit in Menu) ---->B,D

The Name is used as a federation name during the registration process. Therefore, the name should be given first. There is a restriction that in the same federation no two federates can have the same name.

After the Name is specified, Connect button can be used.

Connect button starts the Federation execution and informs RTI that it publishes and subscribes interactions.

The Middle window is used for displaying messages.

The bottom window is used to enter message to send.

The Mail button sends the message in the bottom window.

The Disconnect button resigns the federation execution.

6. Changes

  1. makedoc is added (7.2.1999)
===================================================================The End.
Prepared by H. Timucin Ozdemir, June 23, 1999.
E-mail : timucin@npac.syr.edu
===========================================================================