RE: trouble with pipe advertisement
"Vitaly Vainer" <[email protected]> Sun, 21 May 2006 18:49:45 +0300
| Newsgroups | gmane.comp.java.jxta.user |
|---|---|
| Message-ID | <01dc01c67cee$32d04b10$1e01a8c0@vitaly> |
Hi Segolas,
You can use following approaches:
1. Pipe with "Well-known id" by Daniel Brookshier:
http://wiki.java.net/bin/view/Jxta/WellKnownIDs
2. Advertise pipe as part of service with "well known id". It is actually
the same as first approach. But you're going to discover service instead of
pipe and then get pipe id (which is created random) from service ad.
3. Publish pipe with random id, but with known name:
On the server side (where you create input pipe):
// Create pipe advertisement
PipeAdvertisement pipeAd = (PipeAdvertisement)
AdvertisementFactory.newAdvertisement(
PipeAdvertisement.getAdvertisementType());
pipeAd.setPipeID(IDFactory.newPipeID (yourGroup.getPeerGroupID ());
pipeAd.setType(PipeService.UnicastType); // Or any other type you
want
pipeAd.setName(<your pipe name>);
// Publish pipe advertisement both locally and remotely
yourGroup.getDiscoveryService().publish (pipeAd);
yourGroup.getDiscoveryService().remotePublish (pipeAd);
// Now you can create your input pipe.
On client side (where you create output pipe), discover pipe by name like
this:
yourGroup.getDiscoveryService().getRemoteAdvertisements (null,
DiscoveryService.ADV, "Name", <your pipe name>, 1, new DiscoveryListener ()
{
void discoveryEvent( DiscoveryEvent event ) {
// Put your logic here what to do with discovered pipe
advertisement
}
}
Have fun,
Vitaly.
-----Original Message-----
From: Java [mailto:[email protected]]
Sent: Sunday, May 21, 2006 6:09 PM
To: [email protected]
Subject: trouble with pipe advertisement
hi,
in the tutorial, for sending/receiving messages the two peers load the
pipe advertisement from a xml file.
I don't understand how to create that file? I would like to generate it
dinamically while running the peers, but it seems it's write by hand.
So, if it can be generate at run time, how can I be sure to have the
same pipeId in every advertisement for every peer? (so, becouse id is
generated ramdomly, I think every peer will create a different if from
each other).
If I have to write it by myself, where I can find guidelines for use the
correct syntax? and for the id? If I just cut and paste the example of
tutorial I think my pipe id is the same of every other user doing the same!
thanx
Segolas
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.392 / Virus Database: 268.6.1 - Release Date: 18/05/2006