Exemplo n.º 1
0
        static void Main(string[] args)
        {
            if (args.Length < 1) Uae();

            /// REMOVE ME TO RUN ORIGINAL CLI ///
            WindowMain();
            /// END OF REMOVE_ME ////

            Console.WriteLine("Args[0]: " + args[0]);
            switch (args[0][0])
            {
                //Run server
                case 's':
                case 'S':
                    {
                        Server server = new Server();
                        if (!server.IsKinectKinected)
                        {
                            Console.WriteLine("Kinect must be attached for the server to run, returning.");
                            return;
                        }
                        ConsoleKeyInfo cki;
                        Console.WriteLine("Daemon running on port 3000, press 'Q' to quit");
                        do
                        {
                            cki = Console.ReadKey();
                            ProcessServerKeys(server, cki);
                        } while (cki.Key != ConsoleKey.Q);
                        server.ShutDown();
                    }
                    break;
                //Run client
                case 'c':
                case 'C':
                    {
                        try
                        {
                            ConsoleKeyInfo cki;
                            Client client = new Client();
                            client.Connect();

                            do
                            {
                                cki = Console.ReadKey();
                                ProcessClientKeys(client, cki);
                            } while (cki.Key != ConsoleKey.Q);

                            client.Disconnect();

                        }
                        catch (SystemException ex)
                        {
                            Console.WriteLine("No connection could be established: " + ex.Message);

                        }
                        break;
                    }
                default:
                    Uae();
                    break;
            }
        }
Exemplo n.º 2
0
        static void ProcessClientKeys(Client client, ConsoleKeyInfo cki)
        {
            switch (cki.Key)
            {
                case ConsoleKey.I:
                    Console.WriteLine("Enter Server IP Address:");
                    string strIP = Console.ReadLine();
                    client.Disconnect();
                    client.IpAddr = strIP;
                    client.Connect();
                    break;
                case ConsoleKey.J:
                    client.SendMessageToServer("asd");
                    break;
                case ConsoleKey.H:
                    Console.Clear();
                    Console.WriteLine("Help\n----");
                    Console.WriteLine("I - Change server IP.");
                    Console.WriteLine("J - Request Joint data.");
                    break;
                default:
                    Console.WriteLine("You pressed: " + cki.Key.ToString());
                    break;

            }
        }