com.almende.eve.transport.xmpp
Class XmppService

java.lang.Object
  extended by com.almende.eve.transport.xmpp.XmppService
All Implemented Interfaces:
TransportService

public class XmppService
extends Object
implements TransportService


Constructor Summary
protected XmppService()
           
  XmppService(AgentFactory agentFactory, Map<String,Object> params)
          Construct an XmppService This constructor is called when the TransportService is constructed by the AgentFactory
  XmppService(AgentFactory agentFactory, String host, Integer port, String service)
          initialize the settings for the xmpp service
  XmppService(AgentFactory agentFactory, String host, Integer port, String service, String id)
          initialize the settings for the xmpp service
 
Method Summary
 void connect(String agentId, String username, String password)
          Connect to the configured messaging service (such as XMPP).
 void connect(String agentId, String username, String password, String resource)
          Connect to the configured messaging service (such as XMPP).
 void disconnect(String agentId)
          Disconnect the agent from the connected messaging service (if any)
 String getAgentId(String agentUrl)
          Get the id of an agent from its url.
 String getAgentUrl(String agentId)
          Get the url of an agent from its id.
 List<String> getProtocols()
          Get the protocols supported by the XMPPService.
 JSONResponse send(String senderId, String receiver, JSONRequest request)
          Send a message to an other agent
 void sendAsync(String senderId, String receiver, JSONRequest request, AsyncCallback<JSONResponse> callback)
          Asynchronously Send a message to an other agent
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XmppService

protected XmppService()

XmppService

public XmppService(AgentFactory agentFactory,
                   Map<String,Object> params)
Construct an XmppService This constructor is called when the TransportService is constructed by the AgentFactory

Parameters:
params - Available parameters: {String} host {Integer} port {String} serviceName {String} id

XmppService

public XmppService(AgentFactory agentFactory,
                   String host,
                   Integer port,
                   String service,
                   String id)
initialize the settings for the xmpp service

Parameters:
host -
port -
service - service name
id - state id, to persist the state

XmppService

public XmppService(AgentFactory agentFactory,
                   String host,
                   Integer port,
                   String service)
initialize the settings for the xmpp service

Parameters:
agentFactory -
host -
port -
service - service name
Method Detail

getAgentUrl

public String getAgentUrl(String agentId)
Get the url of an agent from its id. If no agent with given id is connected via XMPP, null is returned.

Specified by:
getAgentUrl in interface TransportService
Parameters:
agentId - The id of the agent
Returns:
agentUrl

getAgentId

public String getAgentId(String agentUrl)
Get the id of an agent from its url. If no agent with given id is connected via XMPP, null is returned.

Specified by:
getAgentId in interface TransportService
Parameters:
agentUrl -
Returns:
agentId

getProtocols

public List<String> getProtocols()
Get the protocols supported by the XMPPService. Will return an array with one value, "xmpp"

Specified by:
getProtocols in interface TransportService
Returns:
protocols

connect

public final void connect(String agentId,
                          String username,
                          String password)
                   throws Exception
Connect to the configured messaging service (such as XMPP). The service must be configured in the Eve configuration

Parameters:
agentUrl -
username -
password -
resource -
Throws:
Exception

connect

public final void connect(String agentId,
                          String username,
                          String password,
                          String resource)
                   throws Exception
Connect to the configured messaging service (such as XMPP). The service must be configured in the Eve configuration

Parameters:
agentUrl -
username -
password -
resource - (optional)
Throws:
Exception

disconnect

public final void disconnect(String agentId)
Disconnect the agent from the connected messaging service (if any)

Parameters:
agentId -

send

public JSONResponse send(String senderId,
                         String receiver,
                         JSONRequest request)
                  throws Exception
Send a message to an other agent

Specified by:
send in interface TransportService
Parameters:
url -
request -
response -
Throws:
Exception

sendAsync

public void sendAsync(String senderId,
                      String receiver,
                      JSONRequest request,
                      AsyncCallback<JSONResponse> callback)
               throws Exception
Asynchronously Send a message to an other agent

Specified by:
sendAsync in interface TransportService
Parameters:
url -
request -
callback - with a JSONResponse
Throws:
Exception

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013 Almende BV. All Rights Reserved.