Package jade.tools.SocketProxyAgent
Class JadeBridge
- java.lang.Object
-
- jade.tools.SocketProxyAgent.JadeBridge
-
public class JadeBridge extends Object
Send an ACL message to the JADE socket proxy agent which is running on a host system and listening on a particular port.
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_AGENT_PROXY_HOSTdefault hoststatic intDEFAULT_AGENT_PROXY_PORTdefault portstatic longDEFAULT_TIMEOUT
-
Constructor Summary
Constructors Constructor Description JadeBridge()Constructor - uses default host and port number.JadeBridge(String aHost, int aPort)Constructor with specified host name and port number.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetHost()get host for this bridgeintgetPort()get port for this bridgeACLMessagesendACL(String aMsg, long timeout)Sends an ACLMessage (in String form) to gateway and returns the reply.ACLMessagesendMessage(ACLMessage aMsg)Send an ACL message and wait for the reply for a default timeout (1 min)ACLMessagesendMessage(ACLMessage aMsg, long timeout)Send an ACL message and wait for the reply for a given timeout in msStringsendMessage(String aMsg)send and receive ACL messages using java.lang.String
-
-
-
Field Detail
-
DEFAULT_TIMEOUT
public static final long DEFAULT_TIMEOUT
- See Also:
- Constant Field Values
-
DEFAULT_AGENT_PROXY_HOST
public static final String DEFAULT_AGENT_PROXY_HOST
default host- See Also:
- Constant Field Values
-
DEFAULT_AGENT_PROXY_PORT
public static final int DEFAULT_AGENT_PROXY_PORT
default port- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JadeBridge
public JadeBridge()
Constructor - uses default host and port number.
-
JadeBridge
public JadeBridge(String aHost, int aPort)
Constructor with specified host name and port number.- Parameters:
aHost- Name of host.aPort- Port number.
-
-
Method Detail
-
getHost
public String getHost()
get host for this bridge- Returns:
- host for this bridge
-
getPort
public int getPort()
get port for this bridge- Returns:
- port for this bridge
-
sendMessage
public String sendMessage(String aMsg)
send and receive ACL messages using java.lang.String- Parameters:
aMsg- The message to send as a string.- Returns:
- The response as a string or error message if anything goes wrong.
-
sendMessage
public ACLMessage sendMessage(ACLMessage aMsg)
Send an ACL message and wait for the reply for a default timeout (1 min)- Parameters:
aMsg- The message to send- Returns:
- The response or error message if anything goes wrong.
-
sendMessage
public ACLMessage sendMessage(ACLMessage aMsg, long timeout)
Send an ACL message and wait for the reply for a given timeout in ms- Parameters:
aMsg- The message to sendtimeout- The timeout for receiving the response- Returns:
- The response or error message if anything goes wrong.
-
sendACL
public ACLMessage sendACL(String aMsg, long timeout) throws IOException, UnknownHostException, SocketException
Sends an ACLMessage (in String form) to gateway and returns the reply.- Parameters:
aMsg- The message to send.timeout- The timeout for receiving the reply- Returns:
- ACLMessage response from gateway.
- Throws:
IOException- If any error occurs during sending or receiving.SocketException- If the socket can't be opened.UnknownHostException- If we can't connect to the host.
-
-