MCAgency

Examples of commonly used MCAgency operations:

Declare an agency as a member of a class:

 public static MCAgency Agency = new MCAgency();

Set the agency's port:

 int temp = 5051;
 Agency.Port = temp;

Start an agency:

 int temp;
 temp = Agency.Initialize();
 if (temp != 0)
     Console.WriteLine("Initialize: " + temp.ToString());

Pause and resume an agency:

 Agency.HaltAgency();
 Agency.ResumeAgency();

Turn off the command prompt thread:

 temp = Agency.SetThreadOff(MCAgency.MC_ThreadIndex_e.MC_THREAD_CP);
 if (temp != 0)
     Console.WriteLine("SetThreadOff: " + temp.ToString());

Load an agent into a local agency:

 String filename = "agent.xml";
 try
 {
     Agency.LoadAgentMigrationMessageFile(filename);
 }
 catch (Exception ex)
 {
     Console.WriteLine("Error loading file: " + ex.Message);
 }
Ideally, the file name should be specified absolutely.

Send an agent to a remote agency:

 String filename = "agent.xml";
 String ip = "192.168.23.93";
 int port = 5051;
 try
 {
     Agency.SendAgentMigrationMessageFile(filename, ip, port);
 }
 catch (Exception ex)
 {
     Console.WriteLine("Error sending file: " + ex.Message);
 }

Find an agent by name:

 MCAgent agent;
 try
 {
     agent = Agency.FindAgentByName("persistent1");
 }
 catch (Exception e)
 {
     Console.WriteLine("Exception: " + e.Message);
 }

Wait for an agent to arrive:

 MCAgent agent;
 Agency.ResetSignal();
 try
 {
     agent = Agency.WaitRetrieveAgent();
 }
 catch (Exception e)
 {
     Console.WriteLine("Exception: " + e.Message);
 }

Wait indefinitely while an agency runs:

 Agency.MainLoop();

Generated on Thu Nov 13 14:22:58 2008 for Mobile-C by  doxygen 1.5.5