public class XMPPPeerInterface extends java.lang.Object implements PeerInterface
A peer interface implementation based upon the Smack library (see http://www.igniterealtime.org for more info).
The connection is configured as a regular chat connection with a server name, port, username and a password. Then peers are either simply all users in this user's roster or all member of a chat room or the union of both.
Constructor and Description |
---|
XMPPPeerInterface() |
Modifier and Type | Method and Description |
---|---|
void |
addPeerPresenceListener(NetworkPeerPresenceListener listener) |
void |
broadcast(Json msg)
Broadcast a message to all members of this peer's group.
|
void |
configure(Json configuration)
Because implementors can be of any type, the configuration is an Object, no constraints
to impose here as there is no common set of configuration properties.
|
XMPPConnection |
getConnection() |
int |
getFileTransferThreshold() |
java.lang.String |
getPassword() |
java.lang.Number |
getPort() |
java.lang.String |
getServerName() |
HyperGraphPeer |
getThisPeer()
Return the
HyperGraphPeer to which this PeerInterface
is bound. |
java.lang.String |
getUser() |
boolean |
isAnonymous() |
boolean |
isAutoRegister() |
boolean |
isConnected()
Return
true if we are currently connected to the network
and false otherwise. |
PeerFilter |
newFilterActivity(PeerFilterEvaluator evaluator) |
PeerRelatedActivityFactory |
newSendActivityFactory() |
void |
removePeerPresenceListener(NetworkPeerPresenceListener listener) |
java.util.concurrent.Future<java.lang.Boolean> |
send(java.lang.Object networkTarget,
Json msg)
Send a message to a specific peer as identified by the
networkTarget parameter. |
void |
setAnonymous(boolean anonymous) |
void |
setAutoRegister(boolean autoRegister) |
void |
setFileTransferThreshold(int fileTransferThreshold) |
void |
setMessageHandler(MessageHandler messageHandler)
The
MessageHandler is responsible for processing messages coming through
the PeerInterface . |
void |
setPassword(java.lang.String password) |
void |
setPort(java.lang.Number port) |
void |
setServerName(java.lang.String serverName) |
void |
setThisPeer(HyperGraphPeer thisPeer)
Internally used to initialize the
PeerInterface , don't call in
application code. |
void |
setUser(java.lang.String user) |
void |
start()
Establish a connection with other peers and make one's presence in the network
known.
|
void |
stop()
Disconnect from the P2P network.
|
public void configure(Json configuration)
PeerInterface
configure
in interface PeerInterface
configuration
- A JSON-like structure holding the network-level configuration parameters.public void start()
PeerInterface
Establish a connection with other peers and make one's presence in the network known.
start
in interface PeerInterface
public boolean isConnected()
PeerInterface
Return true
if we are currently connected to the network
and false
otherwise. Because presence is negotiated asynchronously,
a connection doesn't imply that all peers are already known.
isConnected
in interface PeerInterface
public void stop()
PeerInterface
Disconnect from the P2P network. No more messages are going to be received or sent.
stop
in interface PeerInterface
public PeerRelatedActivityFactory newSendActivityFactory()
newSendActivityFactory
in interface PeerInterface
public java.util.concurrent.Future<java.lang.Boolean> send(java.lang.Object networkTarget, Json msg)
PeerInterface
Send a message to a specific peer as identified by the
networkTarget
parameter.
send
in interface PeerInterface
public void broadcast(Json msg)
PeerInterface
Broadcast a message to all members of this peer's group.
broadcast
in interface PeerInterface
public HyperGraphPeer getThisPeer()
PeerInterface
Return the HyperGraphPeer
to which this PeerInterface
is bound.
getThisPeer
in interface PeerInterface
public PeerFilter newFilterActivity(PeerFilterEvaluator evaluator)
newFilterActivity
in interface PeerInterface
public void addPeerPresenceListener(NetworkPeerPresenceListener listener)
addPeerPresenceListener
in interface PeerInterface
public void removePeerPresenceListener(NetworkPeerPresenceListener listener)
removePeerPresenceListener
in interface PeerInterface
public void setMessageHandler(MessageHandler messageHandler)
PeerInterface
The MessageHandler
is responsible for processing messages coming through
the PeerInterface
. The PeerInterface
merely handles transport
duties, but it delegates the logic for message handling elsewhere. In the HyperGraphDB P2P
framework, that elsewhere is the ActivityManager
.
setMessageHandler
in interface PeerInterface
public void setThisPeer(HyperGraphPeer thisPeer)
PeerInterface
Internally used to initialize the PeerInterface
, don't call in
application code. Implementation should maintain a HyperGraphPeer
member variable and return it in the getThisPeer
method.
setThisPeer
in interface PeerInterface
public XMPPConnection getConnection()
public java.lang.String getServerName()
public void setServerName(java.lang.String serverName)
public java.lang.Number getPort()
public void setPort(java.lang.Number port)
public java.lang.String getUser()
public void setUser(java.lang.String user)
public java.lang.String getPassword()
public void setPassword(java.lang.String password)
public boolean isAnonymous()
public void setAnonymous(boolean anonymous)
public boolean isAutoRegister()
public void setAutoRegister(boolean autoRegister)
public int getFileTransferThreshold()
public void setFileTransferThreshold(int fileTransferThreshold)