5 . Discoverylistener interface
FoundDiscoveryWhen a request is received, the application needs to be notified to obtain a response in theAdvertisement。 InJavaIn the reference implementation, you can giveDiscovery ServiceRegister aListenerObject, whendiscovery Response Messagesdiscoveryservicelistener java< Span ' Times New Roman '; Mso-hansi-font-family: ' Times mso-bidi-font-size:12.0pt ' The role, I will not say more here, if not very understand, find the java< Span ' Times New Roman '; Mso-hansi-font-family: "Times mso-bidi-font-size:12.0pt" The basic book to see L! "
EachDiscoveryservice instance received listener discoveryevent discoveryevent class:
6 . discoveryevent class
The parameters of the Discoveryevent method are used to provide details of the Discovery Response message received by the Discoveryservice instance .
7 . Discovery of remote advertisements
DiscoveryserviceInterface provides an easy way to give otherPeerSendDiscovery Query Message, you don't need to create them yourselfDiscoveryquerymsg The example, but using the getremoteadvertisements method. It has five parameters, the first parameter is Peerid, and if it is empty, it sends the request to all Peer on the local networkand broadcasts through Rendezvous Peer . ( refer to the program line38~39)
8 . Discover the advertisement in the cache
Response to aDiscovery Query MessageOfAdvertisementis automatically saved in the localAdvertisementIn the cacheDiscoverylistener, you do not need to write the cached function in the implementation. and throughDiscoveryserviceof the interfaceGetlocaladvertisementspeer discoverylistener Discoveryresponsemsgadvertisement immediately returns a advertisement enumeration "
9 . Clear the advertisement in the cache
Occasionally, an application may want to erase all caches, such as the application is long unused, and all advertisement are estimated to be invalidated. Clear the advertisement in the cache by using the following method :
public void Flushadvertisement (String id,int type);
Ten . Some questions about the advertisement
LUseAdvertisement: AllAdvertisementnet . Jxta.document.advertisementadvertisementgetdocument method. This method will advertisement document "
l advertisement : /o:p>
peeradvertisement = ( peeradvertisement) advertisementfactory.newadvertisement ("Jxta:pa"); Peeradvertisement.getadvertisementtype ()
L publish advertisement: Publishing has local and remote publishing.
Local publishing methods are:
public void publish (advertisement adv, int type) throws IOException;
public void Publish (advertisement Adv,int Type,long Lifetime,long lifetimeforohers) throws IOException;
Remote publishing methods are:
public void Remotepublish (advertisement adv, int type);
public void Remotepublish (advertisement adv, int type, long lifetime);
-->
-->