Exemple #1
0
        static void Main(string[] args)
        {
            myState = ClientState.Init;

            string paramStr = args.Count() >= 2 ? args[1] : "";

            myClient = new ProcessWrapper();
            myClient.Init(null, IOModelHelper.GetIOType(args[0]), paramStr, ProcessControl);
            myClient.UpdateStatus(ProcessWrapper.ProcesssStatus.Running);

            Console.WriteLine("In the client...console");
            myClient.SendProcessMessage("In the client...msg");
            for (int i = 10; i > 0; i--)
            {
                myClient.SendProcessMessage("[CLIENT] Wait for sync..." + i.ToString());
            }
            while (myState != ClientState.Ending && myClient.CheckProgress() != ProcessWrapper.ProcesssStatus.Ending)
            {
                System.Threading.Thread.Sleep(750);
                if (myState == ClientState.Running)
                {
                    myClient.SendProcessMessage("[CLIENT] Wait...");
                }
            }
            myClient.SendProcessMessage("[CLIENT] quitting client process...");
            myClient.SendProcessMessage("QUIT"); // mark to the server that we're done...
            myClient.UpdateStatus(ProcessWrapper.ProcesssStatus.Ending);

            while (myClient.WaitingForWrite())
            {
                myClient.CheckProgress();
            }

            myClient.Cleanup();
        }
Exemple #2
0
 // ok -> here's the process return string - looking for a QUIT to change the status
 public static void ProcessControl(string s)
 {
     Console.WriteLine(" From Client: <" + s + ">");
     if (s == null || s.StartsWith("uciok") || s.StartsWith("QUIT"))
     {
         myHost.UpdateStatus(ProcessWrapper.ProcesssStatus.Ending);
     }
     else
     {
         myHost.UpdateStatus(ProcessWrapper.ProcesssStatus.Running);
     }
 }
Exemple #3
0
        public static void ProcessControl(string s)
        {
            switch (myState)
            {
            case ClientState.Init:
                if (s.StartsWith("SYNC"))
                {
                    myClient.SendProcessMessage("[CLIENT] Received sync...");
                    myState = ClientState.Running;
                }
                break;

            case ClientState.Running:
                myClient.SendProcessMessage("[CLIENT] Echo: " + s);
                if (s.StartsWith("QUIT"))
                {
                    myClient.SendProcessMessage("[CLIENT] Press Enter to Quit...");
                    myState = ClientState.WaitforEndAck;
                }
                break;

            case ClientState.WaitforEndAck:
                myState = ClientState.Ending;
                break;

            case ClientState.Ending:
                break;
            }
            if (myState == ClientState.Ending)
            {
                myClient.UpdateStatus(ProcessWrapper.ProcesssStatus.Ending);
            }
            else
            {
                myClient.UpdateStatus(ProcessWrapper.ProcesssStatus.Running);
            }
        }