Package edu.rit.chat2 provides the Chat Demo Application Version 2, an M2MI-based chat application. The Chat Demo is intended merely to demonstrate M2MI omnihandle and multihandle invocations and is not intended to be a full-featured chat application.

To run the Chat Demo application, do the following steps on each participating machine:

  1. Configure the M2MI Layer. See package edu.rit.m2mi and class M2MIProperties for further information.
     
  2. Configure the M2MP Layer and run the M2MP Daemon in a separate process. See package edu.rit.m2mp, class M2MPProperties, and class Daemon for further information.
     
  3. Run an instance of the Chat Demo application by typing this command in a separate process:
     
        java edu.rit.chat2.Chat <name>
     
    replacing <name> with the user name. The application displays a chat window.
     

     
  4. Pick the chat room to join from the drop-down list, or click the "New..." button to create a new chat room.
     
  5. Type a line of text into any chat window on any machine and hit return or click the "Send" button. The line of text, prefixed by the user name, shows up in all the chat windows on all the machines that have joined the same chat room.

The Chat program displays a simple chat UI (an instance of class ChatFrame), and the program exports a chat object (an instance of class Chat) that implements interface ChatRef. Each chat room is associated with its own multihandle for interface ChatRef, and the chat object is attached to the multihandle corresponding to the chat room the user joined. When the user sends a line of text in the UI, the line is broadcast to all the chat objects in the chat room by calling putLine() on the multihandle. When each chat object receives a putLine() invocation, it displays the line of text in the chat log in its UI.

To discover which chat rooms are out there, the chat object also implements interface ChatDiscoveryRef. Each chat object periodically broadcasts the name and multihandle of its chat room by calling reportChatRoom() on an omnihandle for interface ChatDiscoveryRef. When each chat object receives a reportChatRoom() invocation, it puts the chat room name and multihandle in a list. When the user selects a chat room, the chat object detaches itself from the previous chat room's multihandle and attaches itself to the new chat room's multihandle.