|
Project JXTA | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.jxta.impl.rendezvous.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 void |
finalize()
Just in case the code that allocated an instance of this object forgot to do "close". |
protected Messenger |
getCachedMessenger()
Deprecated. Prefered 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)
|
void |
messageSendSucceeded(OutgoingMessageEvent event)
|
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, 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)
protected void finalize() throws Throwable
Throwable
public int hashCode()
public String toString()
public void messageSendFailed(OutgoingMessageEvent event)
messageSendFailed
in interface OutgoingMessageEventListener
public void messageSendSucceeded(OutgoingMessageEvent event)
messageSendSucceeded
in interface OutgoingMessageEventListener
public ID getPeerID()
public String getPeerName()
protected void setPeerName(String name)
protected 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.protected Messenger getCachedMessenger()
protected Messenger getCachedMessenger(PeerAdvertisement padv)
padv
- A peer advertisement which will be used for route hints if
a new messenger is needed.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.
|
JXTA J2SE | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |