Exemple #1
0
        private void StartSkeletonThread(object threadInfos)
        {
            SkeletonThreadInfos skeletonThreadInfos = (SkeletonThreadInfos)threadInfos;

            Console.WriteLine("Thread Skeleton sender started");

            while (true)
            {
                Skeleton skeleton = skeletonThreadInfos.SkeletonToWebRTC.Take();

                string formattedSkeletonMessage = "";
                skeleton.SkeletonPoints.ForEach(s => formattedSkeletonMessage += $"{s.X};{s.Y};{s.Z};{s.R};{s.G};{s.B};".Replace(',', '.'));
                formattedSkeletonMessage = formattedSkeletonMessage.Remove(formattedSkeletonMessage.Length - 1, 1);

                // Handle peer disconnected while sending data
                try
                {
                    foreach (KeyValuePair <string, SpitfireRtc> peer in skeletonThreadInfos.RTCPeerConnection)
                    {
                        peer.Value.DataChannelSendText("skeletonChannel", formattedSkeletonMessage);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error, sending data to a disconnected peer : " + ex.Message);
                }
            }
        }
Exemple #2
0
 public SkeletonThreadWebRTC(BlockingCollection <Skeleton> skeletonToWebRTC, Dictionary <string, SpitfireRtc> rtcPeerConnection)
 {
     _skeletonThreadInfos = new SkeletonThreadInfos(skeletonToWebRTC, rtcPeerConnection);
     _skeletonThread      = new Thread(new ParameterizedThreadStart(StartSkeletonThread));
 }