The Kinect TCP Server sends serialized packets of joint data to any connected client at the client's request. Right now, requests are any packets of length() > 0. 0 length packets denote a closed client stream.
Ejemplo 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;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Process keyboard input when server is running
        /// </summary>
        static void ProcessServerKeys(Server server,ConsoleKeyInfo cki)
        {
            switch (cki.Key)
            {
                case ConsoleKey.R:
                    if (server.KinectRaw.Record.IsRecording)
                    {
                        server.KinectRaw.Record.StopRecording();
                        Console.WriteLine("Stop recording");
                    }
                    else
                    {
                        server.KinectRaw.Record.StartRecording();
                        Console.WriteLine("Start recording");
                    }
                    break;
                case ConsoleKey.H:
                    Console.Clear();
                    Console.WriteLine("Help\n----");
                    Console.WriteLine("Q - Stop server.");
                    Console.WriteLine("R - Start/Stop Recording");
                    break;
                default:
                    Console.WriteLine("You pressed: " + cki.Key.ToString());
                    break;

            }
        }