Can we talk?
While the example above provided some insight into message passing via
pipes under JXTA, the shell does actually have some rudimentary
instant-messaging functionality. More a piping demonstration than
talk resembles the *nix
functionality, with each peer establishing its own talk connection to
Pooh registers a talk user (read: talk advertisement) "pooh" and logs
in (read: starts a listener daemon). He tries to find Piglet, who has
not yet registered as a talk user. We use
Shell -s to
create a new shell for Piglet.
|Table of Contents|
Piglet creates a talk user "piglet" and logs in.
Pooh tries again, this time successful in finding Piglet and sending him a greeting.
Piglet receives Pooh's message -- albeit in rather ugly form. Now,
Piglet can't simply reply to Pooh, as talk is a one-way piped message.
So Piglet establishes his own talk session to Pooh. You'll notice the
slightly different form of
talk -u piglet pooh, resulting
in a much cleaner message with proper attribution in Pooh's shell.
Once our friends are ready to conclude their chat, each enters a
period on a line by itself and optionally logs out. Note that talk
advertisements created by
talk -register hang around
between shell sessions; before one can chat, however, one must
talk -login to start a new listener.
Incidently, as I mentioned a moment ago, a talk registration is simply a JXTA
advertisement stored in a local environment variable. We can take a
closer look using our old friends,
Hardly user-friendly in its shell implemention, such talk functionality has already been implemented in InstantP2P, a Java AWT-based GUI chat/file-sharing demonstration application.
To log out of the JXTA shell, type
exit at the
prompt or just close the shell window. Quite a bit of information is
retained between shell sessions including settings, cached peers, groups and
other advertisements. To clear your peer or group caches, use the
-f option mentioned earlier. To start from
scratch, delete the following files/directories:
PlatformConfig, PlatformPeerGroup, jxtaConfig,
Bear in mind that the JXTA shell is only for demonstration and debugging purposes and should not be relied upon to be absolutely stable or emulate a full shell. At the time of this writing, there are a few gotchas and bugs:
- As mentioned above, Windows 2000 users may need to skip the installer and download the latest nightly build ZIP file.
- Sometimes launching the shell does absolutely nothing. Windows (espectially Windows 2000) users may need to log out and back in, or even reboot.
- Shells spawned via
Shell -sare not truly independent. Closing or exiting from the primary shell closes the entire application and all windows.
- Ctrl commands behave very much as Windows GUI users expect, and completely confounds those more at home on the DOS or *nix command-line. ^C isn't interrupt and ^Z isn't suspend; the former copies selected text and the latter does nothing at all. See http://shell.jxta.org/issues/show_bug.cgi?id=2
- Talk is currently extremely slow when not simply talking to yourself from one shell window to another.
Where to go for more...
- The JXTA Position
- Project JXTA Documents
- JXTA Shell Quick Start Guide
- JXTA Shell commands
- "Hello, JXTA!"
Disclosure: The author has been a member of the JXTA's Technical Advisory Committee during its pre-launch development.