Example #1
0
 private void send(IPEndPoint client, Packet packet)
 {
     Client.BeginSend(packet.Data, packet.Data.Length, client, null, null);
 }
Example #2
0
 public void NotifyClients()
 {
     foreach (var client in Clients)
     {
         Packet message = new Packet();
         message.AddString("Hi everyone!");
         send(client, message);
     }
 }
Example #3
0
        /**
         * Reads data from a packet sent from FaceShift
         */
        public void ReceiveFaceShift(byte[] data)
        {
            try
            {
                Packet received = new Packet(data);
                uint blockID = received.NextUInt16();
                uint versionNumber = received.NextUInt16();
                uint blockSize = received.NextUInt32();

                if (blockID == 33433)
                {
                    uint numBlock = received.NextUInt16();

                    for (int i = 0; i < numBlock; i++)
                    {
                        uint newBlockId = received.NextUInt16();
                        uint newVersion = received.NextUInt16();
                        uint newBlockSize = received.NextUInt32();

                        if (newBlockId == 101)
                        {
                            double timeStamp = received.NextDouble();
                            bool flag = received.NextBool();

                            if (flag)
                            {
                                Console.ForegroundColor = ConsoleColor.White;
                                Console.WriteLine("Tracking at ");
                            }
                            else
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                Console.WriteLine("Not Tracking at ");
                            }
                        }
                        else if (newBlockId == 102)
                        {
                            float xRot = received.NextFloat();
                            float yRot = received.NextFloat();
                            float zRot = received.NextFloat();
                            float wRot = received.NextFloat();
                            float xPose = received.NextFloat();
                            float yPose = received.NextFloat();
                            float zPose = received.NextFloat();

                            quatx = xRot;

                            quaty = yRot;
                            quatz = zRot;
                            quatw = wRot;
                            Console.WriteLine(quatx);
                        }
                        else if (newBlockId == 103)
                        {
                            uint numCoeffs = received.NextUInt32();
                            coeffs = new float[numCoeffs];
                            for (int j = 0; j < numCoeffs; j++)
                            {
                                coeffs[j] = received.NextFloat();
                            }
                            //Console.WriteLine(coeffs[41]);
                            //leftblink = coeffs[0];
                            //Console.WriteLine(coeffs[0]);
                        }
                        else if (newBlockId == 104)
                        {
                            float lefttheta = received.NextFloat();
                            float leftphi = received.NextFloat();
                            float righttheta = received.NextFloat();
                            float rightphi = received.NextFloat();

                            //Console.WriteLine(leftphi);
                        }
                        else
                        {
                            received.Skip(System.Convert.ToInt32(newBlockSize));
                        }
                    }
                }
            }
            catch (ObjectDisposedException ex)
            {
            }
        }