예제 #1
0
        /*----< Server processing >------------------------------------*/

        /*
         * - all server processing is implemented with the simple loop, below,
         *   and the message dispatcher lambdas defined above.
         */
        static void Main(string[] args)
        {
            TestUtilities.title("Starting Navigation Server", '=');
            try
            {
                NavigatorServer server = new NavigatorServer();
                server.initializeDispatcher();
                server.comm = new MessagePassingComm.Comm(ServerEnvironment.address, ServerEnvironment.port);

                while (true)
                {
                    CommMessage msg = server.comm.getMessage();
                    if (msg.type == CommMessage.MessageType.closeReceiver)
                    {
                        break;
                    }
                    msg.show();
                    if (msg.command == null)
                    {
                        continue;
                    }
                    CommMessage reply = server.messageDispatcher[msg.command](msg);
                    reply.show();
                    server.comm.postMessage(reply);
                }
            }
            catch (Exception ex)
            {
                Console.Write("\n  exception thrown:\n{0}\n\n", ex.Message);
            }
        }
예제 #2
0
        /*----< Server processing >------------------------------------*/

        /*
         * - all server processing is implemented with the simple loop, below,
         *   and the message dispatcher lambdas defined above.
         */
        private static void Main(string[] args)
        {
            TestUtilities.title("Starting Server", '=');
            Console.WriteLine("\n  Listening to Port: " + ServerEnvironment.port);
            try
            {
                var server = new NavigatorServer();
                server.initializeDispatcher();
                server.comm = new Comm(ServerEnvironment.address, ServerEnvironment.port);
                var directory = Directory.GetParent(Directory.GetParent(ServerEnvironment.root).ToString()).ToString();

                while (true)
                {
                    var msg = server.comm.getMessage();
                    if (msg.type == CommMessage.MessageType.closeReceiver)
                    {
                        break;
                    }
                    msg.show();
                    if (msg.command == null)
                    {
                        continue;
                    }
                    var reply = server.messageDispatcher[msg.command](msg);
                    reply.show();
                    server.comm.postMessage(reply);
                    if (msg.command == "DepAnalysis")
                    {
                        server.comm.postFile("Analysis.txt");
                        File.Delete(directory + "/Analysis.txt");
                    }

                    if (msg.command == "Close")
                    {
                        server.comm.close();

                        Process.GetCurrentProcess().Kill();
                    }
                }
            }
            catch (Exception ex)
            {
                Console.Write("\n  exception thrown:\n{0}\n\n", ex.Message);
            }
        }