Example #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            InputDialog d = new InputDialog("Connection details", "Which server:port ?", "localhost:9999");
            if (d.ShowDialog() != DialogResult.OK)
            {
                throw new InvalidOperationException();
            }
            string[] parts = d.Input.Split(':');
            string host = parts[0];
            string port = parts.Length > 1 ? parts[1] : "9999";

            // Set up GT
            client = new Client(new DefaultClientConfiguration());
            client.ErrorEvent += es => Console.WriteLine(es);
            client.ConnexionRemoved += client_ConnexionRemoved;
            client.Start();

            updates = client.OpenSessionChannel(host, port, SessionUpdatesChannelId,
                ChannelDeliveryRequirements.SessionLike);
            updates.MessagesReceived += updates_SessionMessagesReceived;

            coords = client.OpenStreamedTuple<int, int>(host, port, TelepointersChannelId,
                TimeSpan.FromMilliseconds(50),
                ChannelDeliveryRequirements.AwarenessLike);
            coords.StreamedTupleReceived += coords_StreamedTupleReceived;
        }
Example #2
0
File: Form1.cs Project: solson/DSAE
        void Form1_Load(object sender, EventArgs e)
        {
            if (Program.kinectEnabled)
                kinectClient.RecalculateTable();

            // Set up GT
            var config = new DefaultClientConfiguration();
            client = new GT.Net.Client(config);

            client.ErrorEvent += delegate(ErrorSummary es)
            {
                Console.WriteLine(es);

                if (es.Context is GT.Net.CannotConnectException)
                {
                    Cursor.Show();
                    MessageBox.Show(this, "Could not connect to server. Make sure the ClientRepeater is started.");
                    quitting = true;
                }
            };

            client.ConnexionRemoved += client_ConnexionRemoved;
            client.Start();

            updates = client.OpenSessionChannel(host, port, SessionUpdatesChannelId,
                ChannelDeliveryRequirements.SessionLike);
            updates.MessagesReceived += updates_SessionMessagesReceived;

            coords = client.OpenStreamedTuple<int, int>(host, port, PointersChannelId,
                TimeSpan.FromMilliseconds(25),
                ChannelDeliveryRequirements.AwarenessLike);
            coords.StreamedTupleReceived += coords_StreamedTupleReceived;

            control = client.OpenStringChannel(host, port, ControlChannelId,
                ChannelDeliveryRequirements.CommandsLike);
            control.MessagesReceived += control_MessagesReceived;

            clicks = client.OpenStringChannel(host, port, ClickChannelId,
                ChannelDeliveryRequirements.CommandsLike);
            clicks.MessagesReceived += clicks_MessagesReceived;

            armImages = client.OpenObjectChannel(host, port, ArmImageChannelId,
                ChannelDeliveryRequirements.AwarenessLike);
            armImages.MessagesReceived += armImages_MessagesReceived;

            origins = client.OpenStreamedTuple<int, int>(host, port, OriginsChannelId,
                TimeSpan.FromMilliseconds(25),
                ChannelDeliveryRequirements.AwarenessLike);
            origins.StreamedTupleReceived += origins_StreamedTupleReceived;

            showArms = client.OpenStreamedTuple<bool>(host, port, ShowArmsChannelId,
                TimeSpan.FromMilliseconds(25),
                ChannelDeliveryRequirements.AwarenessLike);
            showArms.StreamedTupleReceived += showArms_StreamedTupleReceived;

            kinectCalibrationChannel = client.OpenObjectChannel(host, port, KinectCalibrationChannelId,
                ChannelDeliveryRequirements.CommandsLike);
            kinectCalibrationChannel.MessagesReceived += kinectCalibrationChannel_MessagesReceived;

            boxGrabChannel = client.OpenObjectChannel(host, port, BoxGrabChannelId,
                ChannelDeliveryRequirements.CommandsLike);
            boxGrabChannel.MessagesReceived += boxGrabChannel_MessagesReceived;

            if (Program.useTouch)
            {
                tuioClient = new TuioClient();
                tuioClient.addTuioListener(this);
                tuioClient.connect();
            }
        }
Example #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            InputDialog d = new InputDialog("Connection details", "Which server:port ?", "localhost:9999");
            if (d.ShowDialog() != DialogResult.OK)
            {
                throw new InvalidOperationException();
            }
            string[] parts = d.Input.Split(':');
            string host = parts[0];
            string port = parts.Length > 1 ? parts[1] : "9999";

            // Aqui vou colocar a chamada para o cliente GT!
            // cGT = new ClienteGT(host, port);

            // Set up GT
            client = new Client(new DefaultClientConfiguration());
            client.ErrorEvent += es => Console.WriteLine(es);

            // Evento do client
            client.ConnexionRemoved += client_ConnexionRemoved;
            client.Start();

            // Evento do client
            client.MessageSent += new MessageHandler(this.MensagemEnviada);

            updates = client.OpenSessionChannel(host, port, SessionUpdatesChannelId,
                ChannelDeliveryRequirements.SessionLike);

            // Evento do updates
            updates.MessagesReceived += updates_SessionMessagesReceived;

            // coords armazena os dados recebidos (é a tupla)
               // coords = client.OpenStreamedTuple<int, int>(host, port, TelepointersChannelId,
               //     TimeSpan.FromMilliseconds(50),
               //     ChannelDeliveryRequirements.AwarenessLike);

            coords = client.OpenStreamedTuple<int, int>(host, port, TelepointersChannelId,
                TimeSpan.FromMilliseconds(50),
                ChannelDeliveryRequirements.AwarenessLike);

            // Evento do coords
            coords.StreamedTupleReceived += coords_StreamedTupleReceived;

            // coords.Identity

            // Utilizar o OpenObjectChannel para enviar um objeto ao invés de enviar uma tupla
            // objts = client.OpenObjectChannel(host, port, ObjectChannelId, ChannelDeliveryRequirements.AwarenessLike);
            objts = client.OpenObjectChannel(host, port, ObjectChannelId, ChannelDeliveryRequirements.CommandsLike);

            objts.MessagesReceived += new Action<IObjectChannel>(objts_MessagesReceived);
        }