public class PeerHandler
extends java.lang.Object
implements java.lang.Runnable
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
connected
Is this peer connected?
|
protected java.lang.String |
debugtext
Debug information as multi-line xml text.
|
static long |
DELAY_OFFLINE
Delay between two pings when a peer is offline.
|
static long |
DELAY_ONLINE
Delay between two pings when a peer is connected.
|
protected RelayHandler |
handler
The relay handler.
|
protected java.util.Map<java.lang.String,PlatformInfo> |
infos
The current platform infos received from the peer (platform id->info).
|
protected boolean |
initial
Is the peer one of the initial peers?
|
protected java.lang.String |
peerid
The peer id (null, if unknown).
|
protected int |
peerstate
The latest known remote peer state (-1 for none).
|
protected boolean |
sent
Have initial platform infos been sent already?
|
protected boolean |
shutdown
The shutdown flag.
|
protected java.lang.String |
url
The URL of the peer.
|
| Constructor and Description |
|---|
PeerHandler(RelayHandler handler,
java.lang.String url,
boolean initial)
Create a timer task.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDebugText(int level,
java.lang.String msg)
Add a debug message.
|
boolean |
checkPlatform(java.lang.String id)
Check if a platform is connected to this peer.
|
void |
clearPlatformInfos()
Clear the list of platform infos.
|
java.lang.String |
getCountryCode()
Get the country code (e.g.
|
java.lang.String |
getDebugText()
Get the debug text.
|
java.lang.String |
getHost()
Get the host name of the peer server.
|
java.lang.String |
getLocation()
Get the location (i.e.
|
PlatformInfo[] |
getPlatformInfos()
Get the platform infos received from the peer.
|
java.lang.String |
getPosition()
Get the location as latitude,longitude.
|
java.lang.String |
getUrl()
Get the peer url.
|
boolean |
isConnected()
Check if the peer is connected.
|
boolean |
isInitial()
Check if the peer is an initial peer.
|
boolean |
isSent()
Check if awareness infos have bneen sent.
|
protected void |
peerOffline()
Called when a peer becomes offline.
|
protected void |
peerOnline()
Called when the peer becomes online.
|
void |
run()
Execute the handler.
|
void |
setConnected(boolean connected)
Set the connection state of the peer.
|
void |
setPeerState(java.lang.String peerid,
int peerstate)
Set the peer state received from remote.
|
void |
setSent(boolean sent)
Set the sent state of the peer.
|
void |
shutdown()
Shutdown the handler.
|
void |
updatePlatformInfo(PlatformInfo info)
Update the platform info.
|
public static final long DELAY_ONLINE
public static final long DELAY_OFFLINE
protected RelayHandler handler
protected java.lang.String url
protected boolean initial
protected boolean connected
protected java.util.Map<java.lang.String,PlatformInfo> infos
protected boolean sent
protected java.lang.String debugtext
protected java.lang.String peerid
protected int peerstate
protected boolean shutdown
public PeerHandler(RelayHandler handler, java.lang.String url, boolean initial)
public java.lang.String getUrl()
public void setSent(boolean sent)
public void setConnected(boolean connected)
public boolean isConnected()
public boolean isSent()
public boolean isInitial()
public void updatePlatformInfo(PlatformInfo info)
public PlatformInfo[] getPlatformInfos()
public void clearPlatformInfos()
public java.lang.String getHost()
public java.lang.String getLocation()
public java.lang.String getCountryCode()
public java.lang.String getPosition()
public java.lang.String getDebugText()
public void addDebugText(int level,
java.lang.String msg)
public boolean checkPlatform(java.lang.String id)
public void run()
run in interface java.lang.Runnablepublic void setPeerState(java.lang.String peerid,
int peerstate)
public void shutdown()
protected void peerOnline()
protected void peerOffline()