Chat example uses the shared objects (Chatter) to publish its messages to all the connected federates. Each object models the user which has Name and Say attributes. Each federate simulates a Chatter object which has Name and Say attributes.
User interface contains four action buttons:
Connect | : | joins the federation execution and creates a new object, |
: | publishes the Say attribute if the federate is joined the execution, | |
Disconnect | : | resigns from federation execution, and deletes the object, |
Exit | : | terminates the program. If the federate did not resign yet, it also resigns from the federation execution. |
The Main menu contains a name button that allows user to enter its name. This name is used as a federate name during the registration.
Chatter2.xml in $(OWRTI_HOME)/xml directory contains the federation definition. Federates simulate objects to publish their messages to other subscribed federates. Chatter object has two attributes: Name and Say. Each federate simulates a Chatter object and subscribes those attributes of Chatter objects. When a federate needs to send a message (Mail), Say attribute is updated. This update is broadcasted by RTI to all the subscribers. When a new Chatter object is defined in the federation execution, RTI informs all the subscribers. When a defined Chatter object is removed from the execution, then RTI informs all the subscribers.
Makefile contains necessary compile parameters. It includes $(OWRTI_HOME)/mk/config.mk configuration file. This file contains variables for:
These variables should be set to the proper directories.
compiles the codes.
Makefile.win contains necessary compile parameters. It includes $(OWRTI_HOME)/mk/config.win configuration file. This file contains variables for:
These variables should be set to the proper directories.
compiles the codes.
Makefile contains necessary parameters. It includes $(OWRTI_HOME)/mk/config.mk configuration file. This file contains variables for:
These variables should be set to the proper directories.
Chatter2.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.
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 3142During the runtime, system goes through the entries in order and uses the first JWORB that runs the OWRTI.
runChat
script starts up the GUI.
Makefile.win contains necessary parameters. It includes $(OWRTI_HOME)/mk/config.win configuration file. This file contains variables for:
These variables should be set to the proper directories.
Chatter2.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.
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 3142During the runtime, system goes through the entries in order and uses the first JWORB that runs the OWRTI.
runChat
script starts up the GUI. (This is a .BAT file).
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:
![]() |
Figure 1. Initial screen when the user does not enter his/her name. |
![]() |
Figure 2. Name option asks the nameof the user. |
![]() |
Figure 3. User enters his/her name in the pop up window. |
![]() |
Figure 4. User can connect to RTI since name is already provided. |
![]() |
Figure 5. After the connection, a user can send message or disconnect from the session. |
![]() |
Figure 6. A snapshot for the ongoing session. |
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. |
ChatBudy.java | : | a chat object representing remote user. |
EntityManager.java | : | a manager for chat objects. |
SimChatBudy.java | : | a chat object representing the local user. |
![]() |
Figure 7. UML diagram for the objects in the program. |
ChatFedAmb.java is the Federation Ambassador implementation for RTI callbacks. These callbacks are forwarded to EntityManager objects.
EntityManager keeps association between the RTI object id and the object representation (ChatBudy) and updates the corresponding object's state based on the RTI messages. It can define an object, delete an object, and update the attributes of an object.
ChatGUI.java controls the users interaction with the RTI. It contains the following buttons:
and Menu with Name and Exit option.
GUI behaves as a finite state machine with 4 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 interaction and Chat objects. Also Connect button defines a new SimChatBudy object.
The Middle window is used for displaying messages.
The bottom window is used to enter a message.
The Mail button sends the message in the bottom window.
The Disconnect button deletes the RTI object and resigns from the federation execution.
===================================================================The End. Prepared by H. Timucin Ozdemir, July 2, 1999. E-mail : timucin@npac.syr.edu ===========================================================================