September 2002
Intermediate to advanced
416 pages
14h 46m
English
In this section, we’ll look at the implementation of the HungryPeer. One new technique is that the HungryPeer must construct the message that it sends to the RestoPeer. With the new technique, the HungryPeer discovers the published pipe advertisement of a RestoPeer; in our last example, the RestoPeer received the pipe advertisement in the HungyPeer’s auction message.
Here’s the implementation of the HunrgyPeer that discovers the pipe:
import java.io.*; import java.util.Enumeration; import java.util.Vector; import net.jxta.peergroup.PeerGroup; import net.jxta.peergroup.PeerGroupFactory; import net.jxta.exception.PeerGroupException; import net.jxta.document.AdvertisementFactory; import net.jxta.document.Advertisement; import net.jxta.document.StructuredDocument; import net.jxta.document.Element; import net.jxta.document.StructuredDocumentFactory; import net.jxta.document.MimeMediaType; import net.jxta.discovery.DiscoveryService; import net.jxta.pipe.PipeService; import net.jxta.pipe.InputPipe; import net.jxta.pipe.PipeID; import net.jxta.pipe.OutputPipe; import net.jxta.endpoint.Message; import net.jxta.protocol.PipeAdvertisement; import net.jxta.protocol.PeerGroupAdvertisement; import net.jxta.id.IDFactory; // The HungryPeer joins the RestoNet peergroup and searches for RestoPeers. // The HungryPeer then establishes a pipe connection to all the RestoPeers // that it discovered. It sends auction requests for French fries to // RestoPeers and then waits for auction ...
Read now
Unlock full access