import EDU.cmu.softagents.misc.KQMLParser.InternalKQMLmessage;
import EDU.cmu.softagents.misc.KQMLParser.ExternalKQMLmessage;
import EDU.cmu.softagents.retsina.Communicator.*;

public class Server1 {

  static Communicator comm = null;

  public static void main (String argv[]) throws CommunicatorException
  {
    comm = new Communicator("TestServer",          // ServerName
			    "angel.cimds.ri",      // ServerHost
			    0,                     // ServerPort
			    new InternalKQMLmessage(),
			    new ExternalKQMLmessage(),
			    null,                  // ServerInfo (none)
			    false);                // not a Retsina Agent

    InputMsgObject iMsgObj = comm.waitOnGetInputMsg();

    ConnectionDescriptor cd = comm.lookupConnection(iMsgObj);
    InternalKQMLmessage msg = (InternalKQMLmessage) iMsgObj.getMsg();

    System.out.println("*** message= "+ msg.getField(msg.CONTENT)+" ***");

    InternalKQMLmessage replyMsg = (InternalKQMLmessage)
	         msg.buildReplyMsg("Reply","ThisIsTheReply", "nothing");
    boolean msgSendOK = comm.sendMsg(cd, replyMsg);

    comm.refuseNewConnections();
    comm.flushMsgsAndStop();
    comm.unRegisterWithANS();
    System.exit(0);   
  }

}
