Skip to main content

Problem with sending a message

2 replies [Last post]
rochejul
Offline
Joined: 2006-11-30
Points: 0

Hi everyone, I use JXTA 2.5_rc1 and I would like to know how I can send a message for only a specifier peer. I see there the method createOutputStream where whe can put the desired peers, but its seems not working.
For example, I used the propagated pipe tutorial.

First problem : client can't see replies. Then I put an input
Second problem : no reply was display. Then I change in the client, in the method "pipeMsgEvent" ==> "MessageElement sel = message.getMessageElement(PropagatedPipeServer.NAMESPACE, PropagatedPipeServer.PONGTAG);" by "MessageElement sel = message.getMessageElement(PropagatedPipeServer.NAMESPACE, PropagatedPipeServer.SRCIDTAG);"
Third problem : replies are displaying, but they come from the local peer !!! Then I put in the client, in the method "pipeMsgEvent" :
if (sel == null || sel.toString().equals(netPeerGroup.getPeerID().toString())) {
return;
}

Now, when I test it, no replies are displaying. I would like to know if I produce mistakes with theses changes. Otherwise, how can I send a message to a specified peer ?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
rochejul
Offline
Joined: 2006-11-30
Points: 0

I see this part of code, but it seems not to work. That why I post this thread. (I think I missed to explain it on the previous post)

I try to create a PipeAdvertissement with the Unicast mode, but it doesn't work too. Maybe the peer must to be a RendezVous peer.

Message was edited by: rochejul

hamada
Offline
Joined: 2003-06-12
Points: 0

In the propagated pipe tutorial are unicast over a propagated pipe

pid = (PeerID) IDFactory.fromURI(new URI(sel.toString()));
if (pid != null) {
// Unicast the Message back. One should expect this to be unicast
// in Rendezvous only propagation mode.
// create a op pipe to the destination peer
if (!pipeCache.containsKey(pid)) {
// Unicast datagram
// create a op pipe to the destination peer
[b] outputPipe = pipeService.createOutputPipe(pipeAdv, Collections.singleton(pid), 1);[/b]
pipeCache.put(pid, outputPipe);
} else {
outputPipe = pipeCache.get(pid);
}
boolean sucess = outputPipe.send(pong);