Пример #1
0
 private static bool IsNode(DaapMessage daapMessage)
 {
     return
         daapMessage.Name == "mdcl" ||
         daapMessage.Name == "mcon" ||
         daapMessage.Name == "mlcl" ||
         daapMessage.Name == "mlit" ||
         daapMessage.Name == "mbcl" ||
         daapMessage.Name == "msrv" ||
         daapMessage.Name == "mccr" ||
         daapMessage.Name == "mlog" ||
         daapMessage.Name == "mupd" ||
         daapMessage.Name == "mudl" ||
         daapMessage.Name == "avdb" ||
         daapMessage.Name == "abro" ||
         daapMessage.Name == "abal" ||
         daapMessage.Name == "abar" ||
         daapMessage.Name == "abcp" ||
         daapMessage.Name == "abgn" ||
         daapMessage.Name == "adbs" ||
         daapMessage.Name == "aply" ||
         daapMessage.Name == "apso" ||
         daapMessage.Name == "prsv" ||
         daapMessage.Name == "arif" ||
         daapMessage.Name == "casp" ||
         daapMessage.Name == "caci"
         ;
 }
Пример #2
0
 private static bool IsNode(DaapMessage daapMessage)
 {
     return
         (daapMessage.Name == "mdcl" ||
          daapMessage.Name == "mcon" ||
          daapMessage.Name == "mlcl" ||
          daapMessage.Name == "mlit" ||
          daapMessage.Name == "mbcl" ||
          daapMessage.Name == "msrv" ||
          daapMessage.Name == "mccr" ||
          daapMessage.Name == "mlog" ||
          daapMessage.Name == "mupd" ||
          daapMessage.Name == "mudl" ||
          daapMessage.Name == "avdb" ||
          daapMessage.Name == "abro" ||
          daapMessage.Name == "abal" ||
          daapMessage.Name == "abar" ||
          daapMessage.Name == "abcp" ||
          daapMessage.Name == "abgn" ||
          daapMessage.Name == "adbs" ||
          daapMessage.Name == "aply" ||
          daapMessage.Name == "apso" ||
          daapMessage.Name == "prsv" ||
          daapMessage.Name == "arif" ||
          daapMessage.Name == "casp" ||
          daapMessage.Name == "caci"
         );
 }
Пример #3
0
        public void ReadFrom(Stream s)
        {
            Name = ReadString(s, 4);
            int length = ReadInt32(s);
            long startPosition = s.Position;
            if (startPosition + length == s.Position)
                return;
            if (IsNode(this))
            {
                while (startPosition + length > s.Position)
                {
                    DaapMessage innerMessage = new DaapMessage();
                    innerMessage.ReadFrom(s);
                    List<DaapMessage> messages;
                    if (!Messages.TryGetValue(innerMessage.Name, out messages))
                    {
                        messages = new List<DaapMessage>();
                        Messages.Add(innerMessage.Name, messages);
                    }
                    messages.Add(innerMessage);
                }
            }
            else
            {
                Value = ReadBytes(s, length);
            }

        }
Пример #4
0
        public void ReadFrom(Stream s)
        {
            Name = ReadString(s, 4);
            int  length        = ReadInt32(s);
            long startPosition = s.Position;

            if (startPosition + length == s.Position)
            {
                return;
            }
            if (IsNode(this))
            {
                while (startPosition + length > s.Position)
                {
                    DaapMessage innerMessage = new DaapMessage();
                    innerMessage.ReadFrom(s);
                    List <DaapMessage> messages;
                    if (!Messages.TryGetValue(innerMessage.Name, out messages))
                    {
                        messages = new List <DaapMessage>();
                        Messages.Add(innerMessage.Name, messages);
                    }
                    messages.Add(innerMessage);
                }
            }
            else
            {
                Value = ReadBytes(s, length);
            }
        }
Пример #5
0
        public void SetSpeakers(params byte[][] ids)
        {
            DacpRequest   request    = new DacpRequest();
            StringBuilder uriBuilder = new StringBuilder("/ctrl-int/1/setspeakers?speaker-id=");

            for (int i = 0; i < ids.Length; i++)
            {
                if (ids[i].Length == 1 && ids[i][0] == 0)
                {
                    uriBuilder.Append("0");
                }
                else
                {
                    uriBuilder.AppendFormat("0x{0}", DaapMessage.ToHexString(ids[i]));
                }
                if (i < ids.Length - 1)
                {
                    uriBuilder.Append(",");
                }
            }
            uriBuilder.Append("&session-id=");
            uriBuilder.Append(SessionId);
            uriBuilder.Append("&hsgid=00000000-066d-31e9-ed58-2b1c969b49c1");
            request.Uri = uriBuilder.ToString();
            Send(request);
        }
Пример #6
0
 protected override void LoadContent()
 {
     if (ContentLength == 0)
     {
         return;
     }
     Content = new DaapMessage();
     Content.ReadFrom(Body);
 }
Пример #7
0
        public DaapMessage GetNewStatus()
        {
            DaapMessage result = GetStatusForRevision(notificationRevisionNumber);

            if (result.Name == "cmst")
            {
                notificationRevisionNumber = result["cmsr"][0].ToInt32();
            }
            return(result);
        }
Пример #8
0
        public static void Main()
        {
            Client client = new Client(new EndPoint()
            {
                Port = 3689, Addresses = { System.Net.IPAddress.Parse("192.168.1.15") }
            });

            client.Login();
            Console.WriteLine(client.SessionId);
            DaapMessage speakers = client.GetSpeakers();

            byte[] speakerId = null;
            foreach (DaapMessage speaker in speakers.Messages["mdcl"])
            {
                if (speaker["caia"] != null)
                {
                    Console.Write("[X] ");
                }
                else
                {
                    Console.Write("[ ] ");
                    speakerId = speaker["msma"][0].Value;
                }
                Console.Write(speaker["minm"][0].ToString() + " ");
                Console.WriteLine("(" + speaker["msma"][0].ToInt64() + ")");
            }
            client.SetSpeakers(new byte[1] {
                0
            }, speakerId);
            speakers = client.GetSpeakers();
            foreach (DaapMessage speaker in speakers.Messages["mdcl"])
            {
                if (speaker["caia"] != null)
                {
                    Console.Write("[X] ");
                }
                else
                {
                    Console.Write("[ ] ");
                }
                Console.Write(speaker["minm"][0].ToString() + " ");
                Console.WriteLine("(" + speaker["msma"][0].ToInt64() + ")");
            }

            Console.ReadLine();
        }