Exemple #1
0
 internal Participant(string id, string name, DTObject extensions)
 {
     this.Id         = id;
     this.Name       = name;
     this.Extensions = extensions;
     this.Data       = DataAnalyzer.SerializeParticipant(this);
 }
Exemple #2
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));
            }
        }
        public static byte[] Serialize(RtpData data)
        {
            using (var temp = ByteBuffer.Borrow(data.Body.Length))
            {
                var array = temp.Item;

                var participantData = DataAnalyzer.SerializeParticipant(data.Participant);
                var extensionssData = GetExtensionsData(data.Header);

                array.Write(participantData.Length);
                array.Write(participantData);

                array.Write(extensionssData.Length);
                array.Write(extensionssData);

                array.Write(data.Body.Length);
                array.Write(data.Body);

                return(array.ToArray());
            }
        }
Exemple #5
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);
         });
     }
 }
Exemple #6
0
 public void WriteExtensions(Action <DTObject> action)
 {
     action(this.Extensions);
     this.Data = DataAnalyzer.SerializeParticipant(this);
 }
Exemple #7
0
 public void SetName(string name)
 {
     this.Name = name;
     this.Data = DataAnalyzer.SerializeParticipant(this);
 }