Peer Discovery Protocol (PDP) for the JXTA Core Protocol (ii)

Source: Internet
Author: User

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);

-->
-->

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.