oreilly.comSafari Books Online.Conferences.
Articles Radar Books  

Learning the JXTA Shell
Pages: 1, 2, 3, 4, 5

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 anything else, talk resembles the *nix write functionality, with each peer establishing its own talk connection to the other.

JXTA>talk -register pooh
......
User : pooh is now registered
JXTA>talk -login pooh
JXTA>talk piglet
......
talk: piglet is not a registered user
JXTA>Shell -s

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

Login
Old Favorites
Getting to know me
Peers
Peer Groups
P2P Piping
Can we talk?
Logout
Gotchas!

JXTA>talk -register piglet
......
User : piglet is now registered
JXTA>talk -login piglet

Piglet creates a talk user "piglet" and logs in.

JXTA>talk piglet
found user's advertisement attempting to connect
talk is connected to user piglet
Type your message. To exit, type "." at begining of line
Hello, Piglet!

Pooh tries again, this time successful in finding Piglet and sending him a greeting.

JXTA>talk: from jxta://59616261646162614A787461503250333DA927976125
4559B209922BACA69E190000000000000000000000000000000000000000000000000
000000000000301 to piglet
Message: Hello, Piglet!

JXTA>talk -u piglet pooh
found user's advertisement attempting to connect
talk is connected to user pooh
Type your message. To exit, type "." at begining of line
And a hello to you too, Pooh.

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.

JXTA>talk piglet
found user's advertisement attempting to connect
talk is connected to user piglet
Type your message. To exit, type "." at begining of line
Hello, Piglet!

talk: from piglet to pooh
Message: And a hello to you too, Pooh.

.
JXTA>talk -logout pooh
JXTA>talk: stop listening for user :pooh

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, env and cat.

JXTA>env
stdout = Default OutputPipe (class net.jxta.impl.shell.ShellOutputPipe)
stdin = Default InputPipe (class net.jxta.impl.shell.ShellInputPipe)
...
adv0 = local jxta advertisement (class net.jxta.impl.protocol.PipeAdv)
stdgroup = Default Group (class net.jxta.impl.peergroup.StdPeerGroup)

JXTA>cat adv0
<?xml version="1.0"?>

<!DOCTYPE jxta:PipeAdvertisement>

<jxta:PipeAdvertisement>
  <id>
    jxta://59616261646162614A787461503250333DA9279761254559B209922
    BACA69E1900000000000000000000000000000000000000000000000000000
    00000000301
  </id>
  <name>
    JxtaTalkUserName:pooh
  </name>
</jxta:PipeAdvertisement>

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.

Logout

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, and cm.

Gotchas!

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 -s are 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...


Disclosure: The author has been a member of the JXTA's Technical Advisory Committee during its pre-launch development.



P2P Weblogs

Richard Koman Richard Koman's Weblog
Supreme Court Decides Unanimously Against Grokster
Updating as we go. Supremes have ruled 9-0 in favor of the studios in MGM v Grokster. But does the decision have wider import? Is it a death knell for tech? It's starting to look like the answer is no. (Jun 27, 2005)

> More from O'Reilly Developer Weblogs


More Weblogs
FolderShare remote computer search: better privacy than Google Desktop? [Sid Steward]

Data Condoms: Solutions for Private, Remote Search Indexes [Sid Steward]

Behold! Google the darknet/p2p search engine! [Sid Steward]

Open Source & The Fallacy Of Composition [Spencer Critchley]