コード例 #1
0
 /**
  * * Executes the CycProxyFactory thread and processes the the (cyc-to-agent-manager-init
  * <image-id> <base-port>) message.
  */
 public void run() {
   Log.current.println("Begin CycProxyFactory thread");
   try {
     cycConnection = new CycConnection(cfaslSocket);
   } catch (Exception e) {
     Log.current.println("Exception creating CycConnection " + e.getMessage());
     throw new RuntimeException("Exception creating CycConnection: " + e.getMessage());
   }
   CycList cycToAgentManagerInitMessage = null;
   try {
     // cycConnection.traceOnDetailed();
     cycToAgentManagerInitMessage = cycConnection.receiveBinaryApiRequest();
   } catch (Exception e) {
     Log.current.println("Exception with CycConnection: " + e.getMessage());
     return;
   }
   if (!cycToAgentManagerInitMessage
       .first()
       .equals(CycObjectFactory.makeCycSymbol("cyc-to-agent-manager-init"))) {
     Log.current.println("Invalid initialization message: " + cycToAgentManagerInitMessage);
     return;
   }
   String cycImageId = (String) cycToAgentManagerInitMessage.second();
   int basePort = ((Integer) cycToAgentManagerInitMessage.third()).intValue();
   String myAgentName = "cyc-api-service-" + cycImageId;
   CycProxy cycProxy = new CycProxy(myAgentName, verbosity);
   cycProxy.agentsCycConnection = cycConnection;
   CycAgentInfo cycAgentInfo = new CycAgentInfo(basePort, cycImageId, cycProxy);
   AgentManager.cycAgents.put(myAgentName, cycAgentInfo);
   cycProxy.initializeAgentCommunity();
   cycProxy.handleMessagesFromCyc();
 }
コード例 #2
0
 /** Closes the cyc connection. */
 public void close() {
   try {
     cycConnection.close();
   } catch (Exception e) {
     Log.current.println("Exception closing socket i/o: " + e);
   }
 }