Esempio n. 1
0
        private void HandleParticipantUpdate(Message message)
        {
            var participant      = DataAnalyzer.DeserializeParticipant(message.Origin, message.Body);
            var multicastAddress = message.Header.GetValue <string>(MessageField.MulticastAddress);

            this.Client.UseMulticast(multicastAddress, (multicast) =>
            {
                participant.Orgin = message.Origin;
                multicast.AddOrUpdateParticipant(participant);
            });
        }
        public static RtpData Deserialize(string orgin, byte[] data)
        {
            using (var temp = ByteBuffer.Borrow(data.Length))
            {
                var array = temp.Item;
                array.Write(data);

                var participantDataLength = array.ReadInt32();
                var participantData       = array.ReadBytes(participantDataLength);

                var extensionsDataLength = array.ReadInt32();
                var extensionsData       = array.ReadBytes(extensionsDataLength);

                var bodyLength = array.ReadInt32();
                var body       = array.ReadBytes(bodyLength);

                return(new RtpData(DataAnalyzer.DeserializeParticipant(orgin, participantData), CreateExtensions(extensionsData), body));
            }
        }
Esempio n. 3
0
 private void HandleParticipantLeave(Message message)
 {
     if (message.Body.Length > 0)
     {
         //根据成员删除
         var participant      = DataAnalyzer.DeserializeParticipant(message.Origin, message.Body);
         var multicastAddress = message.Header.GetValue <string>(MessageField.MulticastAddress);
         this.Client.UseMulticast(multicastAddress, (multicast) =>
         {
             multicast.RemoveParticipant(participant);
         });
     }
     else
     {
         //根据发送源更新成员,这意味着对方掉线了
         var multicastAddress = message.Header.GetValue <string>(MessageField.MulticastAddress);
         this.Client.UseMulticast(multicastAddress, (multicast) =>
         {
             multicast.RemoveParticipant(message.Origin);
         });
     }
 }