Esempio n. 1
0
 private void DumpBeacon(BeaconPacket bp)
 {
     Debug.WriteLine("BeaconPacket dump: \n" +
                     "  Alive=" + bp.Alive.ToString() + "\n" +
                     "  BGColor=" + bp.BGColor.ToString() + "\n" +
                     "  ID=" + bp.ID.ToString() + "\n" +
                     "  Role=" + bp.Role.ToString() + "\n" +
                     "  FName=" + bp.FriendlyName + "\n" +
                     "  Name=" + bp.Name + "\n" +
                     "  Time=" + bp.Time.ToString() + "\n\n");
 }
Esempio n. 2
0
 // Find index of a packet with a matching name.  Return -1 if not found
 public int Lookup(BeaconPacket bp)
 {
     for (int index = 0; index < packets.Count; index++)
     {
         BeaconPacket bp1 = (BeaconPacket)packets[index];
         if (bp1.Name == bp.Name)
         {
             return(index);
         }
     }
     return(-1);
 }
Esempio n. 3
0
        /// <summary>
        /// receive frame from Presenter 3
        /// </summary>
        /// <param name="bc"></param>
        /// <param name="ssrc"></param>
        private void presenterRTNavReceive(BufferChunk bc, uint ssrc)
        {
            BinaryFormatter bf  = new BinaryFormatter();
            Object          obj = null;

            try
            {
                MemoryStream ms = new MemoryStream((byte[])bc);
                obj = bf.Deserialize(ms);

                //Debug.WriteLine("presenterRTNavReceive deserialized bc Size=" + bc.Length.ToString());

                //The BeaconPacket is used to allow us to latch on to a presenter if we are not
                //currently listeneing to anyone, and to update the active presenters count
                //on the main form.  Beacon packet also contains the background color, so we will
                //send it to scriptQueue as well.
                if (obj is CP3.Network.Chunking.Chunk)
                {
                    string friendlyName;
                    int    role = CP3Manager.CP3Manager.AnalyzeChunk((CP3.Network.Chunking.Chunk)obj, out friendlyName);
                    if (1 == role)
                    {
                        BeaconPacket bp = new BeaconPacket(ssrc.ToString(), (int)ssrc, ssrc.ToString(),
                                                           ViewerFormControl.RoleType.Presenter,
                                                           DateTime.Now, System.Drawing.Color.White);
                        ReceiveBeacon(bp, ssrc);
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine("PresenterRTNavReceive exception deserializing message. size=" + bc.Length.ToString() +
                                " exception=" + e.ToString());
                //eventLog.WriteEntry(e.Message );
                return;
            }

            if (ssrc != currentPresenterSSRC)             // not from the currently selected ssrc
            {
                return;
            }

            if (scriptQueue != null)
            {
                scriptQueue.Enqueue(obj);
            }

            scriptCount++;            //this is not quite right because not all frames result in scripts.
        }
Esempio n. 4
0
        public void Add(BeaconPacket bp, DateTime time)
        {
            BeaconPacket newPacket = new BeaconPacket(bp.Name, bp.ID, bp.FriendlyName, bp.Role, time, bp.BGColor);

            int index = Lookup(bp);

            if (index != -1)
            {
                packets[index] = newPacket;
            }
            else
            {
                packets.Add(newPacket);
            }
        }
Esempio n. 5
0
        private void ReceiveBeacon(BeaconPacket bp, uint thisSSRC)
        {
            DateTime dt = DateTime.Now;

            livenessMonitor.Add(bp, dt);

            if ((bp.Role == ViewerFormControl.RoleType.Presenter) && (currentPresenterSSRC == 0))
            {
                currentPresenterSSRC = thisSSRC;
            }

            // This happens if a presenter we're listening to changes roles.
            if ((bp.Role != ViewerFormControl.RoleType.Presenter) && (currentPresenterSSRC == thisSSRC))
            {
                currentPresenterSSRC = 0;
            }
        }
Esempio n. 6
0
        // Count the viewers and presenters since a given time.
        public int LivePackets(DateTime time, bool isPresenter)
        {
            int count = 0;

            ViewerFormControl.RoleType role;
            if (isPresenter)
            {
                role = ViewerFormControl.RoleType.Presenter;
            }
            else
            {
                role = ViewerFormControl.RoleType.Viewer;
            }

            for (int i = 0; i < packets.Count; i++)
            {
                BeaconPacket bp = (BeaconPacket)packets[i];
                if ((bp.Time >= time) && (bp.Role == role))
                {
                    count++;
                }
            }
            return(count);
        }