|
JXTA | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.jxta.impl.rendezvous.PeerConnection
public abstract class PeerConnection
Manages a connection with a remote client or a rendezvous peer.
Field Summary | |
---|---|
protected Messenger |
cachedMessenger
A cached messenger to be used for sending messages to the remote peer. |
protected boolean |
connected
If true then we believe we are still connected to the remote peer. |
protected EndpointService |
endpoint
|
protected PeerGroup |
group
|
protected long |
leasedTil
The absolute time in milliseconds at which we expect this connection to expire unless renewed. |
protected ID |
peerid
ID of the remote peer. |
protected String |
peerName
Cached name of the peer for display purposes. |
Constructor Summary | |
---|---|
PeerConnection(PeerGroup group,
EndpointService endpoint,
ID peerid)
Constructor for the PeerConnection object |
Method Summary | |
---|---|
protected void |
connect(long leaseDuration)
Declare that we are connected for the specified amount of time. |
boolean |
equals(Object obj)
performs PeerID comparison |
protected Messenger |
getCachedMessenger()
Deprecated. Preferred style is to pass the connection object around and use the sendMessage method rather than getting the messenger. |
protected Messenger |
getCachedMessenger(PeerAdvertisement padv)
Return a messenger suitable for communicating to this peer. |
long |
getLeaseEnd()
Time at which the lease will expire in absolute milliseconds. |
ID |
getPeerID()
Get the peer id of the peer associated with this connection. |
String |
getPeerName()
Get the peer name. |
int |
hashCode()
|
boolean |
isConnected()
Test if the connection is still active. |
void |
messageSendFailed(OutgoingMessageEvent event)
The message identified by the event could not be sent. |
void |
messageSendSucceeded(OutgoingMessageEvent event)
The message identified by the event was successfully sent. |
boolean |
sendMessage(Message msg,
String service,
String param)
Send a message to the remote peer. |
void |
setConnected(boolean isConnected)
Set the connection state. |
protected void |
setLease(long leaseDuration)
Set the lease duration in relative milliseconds. |
protected void |
setPeerName(String name)
set the peer name. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final PeerGroup group
protected final EndpointService endpoint
protected final ID peerid
protected String peerName
protected volatile boolean connected
protected long leasedTil
protected Messenger cachedMessenger
Constructor Detail |
---|
public PeerConnection(PeerGroup group, EndpointService endpoint, ID peerid)
group
- group contextendpoint
- the endpoint service to use for sending messages.peerid
- destination peeridMethod Detail |
---|
public boolean equals(Object obj)
equals
in class Object
public int hashCode()
hashCode
in class Object
public String toString()
toString
in class Object
public void messageSendFailed(OutgoingMessageEvent event)
OutgoingMessageEvent.getFailure()
. Failures while sending
messages have several causes :
IOException
means that the messenger cannot
send the message and the messenger will accept no further messages
to be sent.RuntimeException
mean that the message was
not sent, but retries may or may not be possible based upon the
status returned by Messenger.isClosed()
.null
means that the message was not sent, but may
be retried. Usually the failure is due to local resource limits
being exceeded. Attempts may be made to later resend the message,
usually after waiting for congestion to clear.
messageSendFailed
in interface OutgoingMessageEventListener
event
- the eventpublic void messageSendSucceeded(OutgoingMessageEvent event)
messageSendSucceeded
in interface OutgoingMessageEventListener
event
- the eventpublic ID getPeerID()
public String getPeerName()
protected void setPeerName(String name)
name
- the peer nameprotected void setLease(long leaseDuration)
leaseDuration
- the lease duration in relative milliseconds.public long getLeaseEnd()
protected void connect(long leaseDuration)
leaseDuration
- The duration of the lease in relative milliseconds.public boolean isConnected()
public void setConnected(boolean isConnected)
isConnected
- The new connected state. Be very careful when
setting true
state without setting a new lease.@Deprecated protected Messenger getCachedMessenger()
null
if
none is available.protected Messenger getCachedMessenger(PeerAdvertisement padv)
padv
- A peer advertisement which will be used for route hints if
a new messenger is needed.
null
if
none is available.public boolean sendMessage(Message msg, String service, String param)
msg
- the message to send.service
- The destination service.param
- Parameters for the destination service.
false
. A true
result does not mean
that the destination peer will receive the message.
|
JXSE | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |