|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.sri.oaa2.com.LibCom
Provides communications methods for the agentlib
| Field Summary | |
IclDb |
commdb
|
static int |
MAXBACKLOG
|
protected java.lang.String[] |
mCmdLine
|
| Constructor Summary | |
LibCom(LibComProtocol inProtocol,
java.lang.String[] inCmdLine)
Constructor |
|
| Method Summary | |
int |
availTerms()
|
boolean |
comAddInfo(java.lang.String connectionId,
IclTerm newInfo)
Add NewInfo to the database entry for the client connection described by ConnectionId. |
void |
comAddProtocol(LibComProtocol inProtocol)
|
boolean |
comConnect(java.lang.String connectionId,
IclTerm address,
IclList params)
Connect a client agent to the Facilitator found at Address. |
boolean |
comConnected(java.lang.String connectionId)
Determines whether a given connection is actually valid. |
boolean |
comDisconnect(java.lang.String connectionId,
IclList params)
Shut down the connection between client agent and Facilitator as named by ConnectionId. |
java.lang.String |
comGetConnectionFromInfo(IclTerm conStruct)
purpose: Looks up a connection that contains a given information returns: Null if fail, an IclTerm if success |
java.lang.String |
comGetConnectionId(IclTerm Info)
purpose: Looks up a connection that contains the given information in the info list. |
IclTerm |
comGetInfo(java.lang.String connectionId,
IclTerm infoIn)
Find and return information associated with Info stored in the client database for the connection named ConnectionId. |
boolean |
comListenAt(java.lang.String connectionId,
IclTerm params,
IclTerm address)
Given a connection ID and an address, initiate a server connection. |
void |
ComPrintDB(java.lang.String inMessage)
|
boolean |
comSendData(java.lang.String connectionId,
IclTerm t)
|
IclList |
getAllValidConnections()
Returns an IclList containing all valid connections' ids. |
java.util.HashMap |
getBuffers()
|
java.lang.String[] |
getCmdLine()
|
IclTerm |
getNextTermRR()
Get next term from any connection, in round robin fashion |
boolean |
haveTerms()
|
void |
notifyConnectionEstablished(LibComConnection newConnection,
java.lang.String connectionId,
IclTerm address,
IclList params)
Notifies the listener that a new connection has been established. |
void |
notifyConnectionShutDown(LibComConnection connection,
com.sri.oaa2.simplefac.ConnectionId connectionId,
java.lang.Throwable ex)
Notifies the listener that a new connection has been established. |
void |
processIncomingTerm(java.lang.String connectionId,
IclTerm t)
processIncomingMessage(String connectionId, String message) |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int MAXBACKLOG
public IclDb commdb
protected java.lang.String[] mCmdLine
| Constructor Detail |
public LibCom(LibComProtocol inProtocol,
java.lang.String[] inCmdLine)
| Method Detail |
public void comAddProtocol(LibComProtocol inProtocol)
public boolean comConnect(java.lang.String connectionId,
IclTerm address,
IclList params)
For successful connections, comConnect() adds a new entry to a database maintained by LibCom, also called the InfoList. LibCom uses this database for managing the the set of connections, and for Java, a corresponding set of execution threads (one per connection). The database contains a key which identifies the connection (ConnectionId), a list of ICL Terms that describe the connection (e.g., status(connected), connection(8)), and a pointer to a buffer which is used for storing data received from the Facilitator for the client.
A client agent may connect to only one Facilitator. The value for connectionId must be 'parent' or "parent" for the Prolog and Java implementations respectively. Future releases will support connections to multiple facilitators by a single client.
connectionId - a Prolog ICL atom or Java String that specifies the name of
the Facilitator connection.params - a list of IclTerms. THe only param used is "other_address". If
"other_address" is defined, it is used as "other_address" in the
connection_info.address - may be either an explicit connection address for a Facilitator
or an uninitialized variable. The latter is most commonly used.
Examples include tcp("test.ai.sri.com", "7576") and tcp(Host, Port).
Use of an uninitialized variable for Address cues comConnect to determine the host
and port according to the following order of priority:
Highest: retrieve host and port from command line arguments
-oaa_connect tcp(Host,Port)
Example:
-oaa_connect "tcp('test.ai.sri.com', 7576)"
Next: retrieve this information from the environment variables OAA_CONNECT.
Lowest: use information found in the configuration file setup.pl. Entries must be of the form
default_facilitator(tcp(Host,PortNumber)).
For example
default_facilitator(tcp('test.ai.sri.com', 7576)).
comConnect() locates setup.pl by first looking in the local directory, then if not found,
looks in the user's home directory.
Example:
// First, connect to the facilitator
if (!oaa.getComLib().comConnect("parent", IclTerm.fromString(true, "tcp(Host,Port)"))){
printError("Could not connect");
return;
}
LibOaa.oaaRegister(java.lang.String, java.lang.String, com.sri.oaa2.icl.IclTerm, com.sri.oaa2.icl.IclList),
LibOaa.oaaRegisterCallback(java.lang.String, com.sri.oaa2.lib.OAAEventListener),
LibOaa.oaaMainLoop(boolean),
LibOaa.oaaDisconnect(java.lang.String, com.sri.oaa2.icl.IclList),
comDisconnect(java.lang.String, com.sri.oaa2.icl.IclList)
public void notifyConnectionEstablished(LibComConnection newConnection,
java.lang.String connectionId,
IclTerm address,
IclList params)
LibComServerListener
notifyConnectionEstablished in interface LibComServerListenernewConnection - the new connectionconnectionId - the id for the new connectionaddress - the connection's addressparams - any parameters to use when adding the connection to the
comm db.
public boolean comDisconnect(java.lang.String connectionId,
IclList params)
comDisconnect() immediatly disconnects the client-Facilitator connection with no delays (e.g., remaining data on the connection is discarded) and removes the entry corresponding to ConnectionId from the LibCom database. For the Java implementation, comDisconnect() also kills the thread of execution associated with this connection.
It is strongly suggested that oaaDisconnect be called directly rather than comDisconnect() as the former performs other client clean-up activities necessary for proper shutdown of a connection.
params - a list of IclTerms which indicate options for performing the disconnection.
At present, only one parameter is recognized, TBD. It signals to the
Facilitator that the client is temporarily disconnecting (e.g., robot
out of range, or PDA temporarily off line). Future service requests
received by the Facilitator for the disconnected client will be queued by
the Facilitator and delivered upon reconnection.
comConnect(java.lang.String, com.sri.oaa2.icl.IclTerm, com.sri.oaa2.icl.IclList),
LibOaa.oaaDisconnect(java.lang.String, com.sri.oaa2.icl.IclList)
public boolean comListenAt(java.lang.String connectionId,
IclTerm params,
IclTerm address)
public boolean comSendData(java.lang.String connectionId,
IclTerm t)
public IclTerm comGetInfo(java.lang.String connectionId,
IclTerm infoIn)
comAddInfo(java.lang.String, com.sri.oaa2.icl.IclTerm)public java.lang.String comGetConnectionFromInfo(IclTerm conStruct)
conStruct - a com_connection_info structpublic java.lang.String comGetConnectionId(IclTerm Info)
Info - an info parameter struct (ex: other_address(..))public boolean comConnected(java.lang.String connectionId)
connectionId - a Java String that specifies the name of the Facilitator connection.public IclList getAllValidConnections()
public boolean comAddInfo(java.lang.String connectionId,
IclTerm newInfo)
connectionId - a Java String that specifies the name of the Facilitator connection.newInfo - a Java String which contains one or more elements to be
stored for this client such as status(S), type(T), or protocol(P);
e.g., "status(connected), protocol(tcp)".
comGetInfo(java.lang.String, com.sri.oaa2.icl.IclTerm),
comConnect(java.lang.String, com.sri.oaa2.icl.IclTerm, com.sri.oaa2.icl.IclList)public IclTerm getNextTermRR()
public void processIncomingTerm(java.lang.String connectionId,
IclTerm t)
LibComClient
processIncomingTerm in interface LibComClientpublic boolean haveTerms()
public int availTerms()
public java.util.HashMap getBuffers()
public java.lang.String[] getCmdLine()
public void ComPrintDB(java.lang.String inMessage)
public void notifyConnectionShutDown(LibComConnection connection,
com.sri.oaa2.simplefac.ConnectionId connectionId,
java.lang.Throwable ex)
LibComListener
notifyConnectionShutDown in interface LibComListenerconnection - the connection which shut downconnectionId - the id for the connection which shut downex - an error detailing the reason the connection was shut down
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||