ASChat

ASChat demonstrates how to build a peer-to-peer distributed application using ActiveSpaces: a multi-user chat room.

ASChat exchanges messages with another running instance of ASChat. You should run two instances of ASChat to see the exchange of messages in the space.

ASChat does not use the same default space as the other examples, but defines its own simple space (ASChat), which has the following two fields:

  • A mandatory key field called name of type String
  • An optional field called message of type String

Each instance of ASChat that you run uses a single tuple to store the user's name and message for 'putting' into the space. The program loops, waiting for the user to enter a new message. The new message then replaces the old message in the tuple before the tuple is put into the space again.

A listener callback is implemented for puts and takes on the space. When another ASChat instance puts or takes messages to or from the space, the listener callback is invoked and information about the put or take is displayed.

One interesting thing to note about how ASChat is implemented is that it uses the Admin interface to define the ASChat space. Most of the other examples define a space using the SpaceDef interface.