From 0c1b0cdf903114c4214f6b9298ecd440972a42b5 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期五, 14 一月 2022 13:13:56 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/wjc' into wxr0114

---
 HDL_ON/UI/UI2/FuntionControlView/Music/SendMethod.cs |  922 ++++++---------------------------------------------------
 1 files changed, 97 insertions(+), 825 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/SendMethod.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/SendMethod.cs
index dd36144..70026c6 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/Music/SendMethod.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/Music/SendMethod.cs
@@ -4,883 +4,155 @@
 using System.Net.Sockets;
 using System.Security;
 using System.Text;
+using HDL_ON.DAL.Server;
+using HDL_ON.Entity;
 using Shared;
 
 namespace HDL_ON.UI.Music
 {
     public class SendMethod
     {
-        /// <summary>
-        ///鎼滅储A31闊充箰鎾斁鍣�
-        /// </summary>
-        /// <param name="action"></param>
-        /// <param name="time"></param>
-        /// <param name="uid"></param>
-        public static void Seach(Action<A31MusicModel> action, int time = 5 * 1000, string uid = "AllUniqueDeviceName")
+        private static SendMethod sMethod=null;    
+        public static SendMethod mMethod
         {
-            System.Threading.Tasks.Task.Run(() =>
+            get
             {
-                System.Net.Sockets.UdpClient udpClient = null;
-                int localPort = 65535;
-                for (; 1024 < localPort; localPort--)
+                if (sMethod == null)
                 {
-                    try
-                    {
-                        udpClient = new System.Net.Sockets.UdpClient(localPort);
-                        break;
-                    }
-                    catch (Exception e) { System.Console.WriteLine(e.Message); }
+                    sMethod = new SendMethod();
                 }
+                return sMethod;
+            }
 
-                System.Threading.Tasks.Task.Run(() =>
-                {
-                    var tempDateTime = DateTime.Now;
-                    while (udpClient != null)
-                    {
-                        try
-                        {
-                            if (time < (DateTime.Now - tempDateTime).TotalMilliseconds)
-                            {
-                                var tempBytes = System.Text.Encoding.UTF8.GetBytes("瀹屾垚");
-                                udpClient.Send(tempBytes, tempBytes.Length, new System.Net.IPEndPoint(System.Net.IPAddress.Parse("127.0.0.1"), localPort));
-                            }
-                            else
-                            {
-                                var stringBuilder = new StringBuilder();
-                                stringBuilder.AppendLine("M-SEARCH * HTTP/1.1");
-                                stringBuilder.AppendLine("St: ssdp:wiimudevice");
-                                stringBuilder.AppendLine("Mx: 3");
-                                stringBuilder.AppendLine("Host: 239.255.255.250:1900");
-                                stringBuilder.AppendLine("Man: \"ssdp:discover\"");
-                                stringBuilder.AppendLine();
-                                var tempBytes = System.Text.Encoding.ASCII.GetBytes(stringBuilder.ToString());
-                                //璇锋眰鑾峰彇A31鏈嶅姟鍣ㄤ俊鎭�
-                                udpClient.Send(tempBytes, tempBytes.Length, new System.Net.IPEndPoint(System.Net.IPAddress.Parse("239.255.255.250"), 1900));
-                                udpClient.Send(tempBytes, tempBytes.Length, new System.Net.IPEndPoint(System.Net.IPAddress.Parse("239.255.255.250"), 1900));
-                                //濡傛灉1000姣娌℃湁鏁版嵁鍥炲锛屽氨鍏抽棴褰撳墠Socket锛屼笉鍐嶇瓑寰呮帴鏀舵暟鎹�
-                            }
-                            System.Threading.Thread.Sleep(500);
-                        }
-                        catch (Exception e) { System.Console.WriteLine(e.Message); }
-                    }
-                });
-                while (true)
-                {
-                    try
-                    {
-                        //鎺ユ敹鍥炴潵鐨勬暟鎹�
-                        var remoteIpEndPoint = new System.Net.IPEndPoint(0, 0);
-                        //寮�濮嬪湪杩欓噷绛夊緟鎺ユ敹鏁版嵁锛�
-                        var receviceBytes = udpClient.Receive(ref remoteIpEndPoint);
-                        if (receviceBytes == null)
-                        {
-                            break;
-                        }
-                        if ("瀹屾垚" == System.Text.Encoding.UTF8.GetString(receviceBytes))
-                        {
-                            if (action != null)
-                            {
-                                //琛ㄧず瀹屾垚浜�
-                                action(null);
-                            }
-                            try
-                            {
-                                udpClient.Close();
-                                udpClient = null;
-                            }
-                            catch (Exception e) { System.Console.WriteLine(e.Message); }
-                            break;
-                        }
-
-                        var sr = new System.IO.StreamReader(new System.IO.MemoryStream(receviceBytes, 0, receviceBytes.Length));
-                        string tempLine = null;
-                        string ipAddress = null;
-                        int port = 0;
-                        string uniqueDeviceName = null;
-                        //涓�琛屼竴琛屾暟鎹垽鏂紝鎵惧嚭闇�瑕佺殑淇℃伅
-                        while ((tempLine = sr.ReadLine()) != null)
-                        {
-                            //鎵惧嚭Ip鍦板潃鐩稿叧鐨勪俊鎭�
-                            //System.Console.WriteLine (tempLine);
-                            if (tempLine.StartsWith("LOCATION: http://"))
-                            {
-                                tempLine = tempLine.Replace("LOCATION: http://", "").Split('/')[0];
-                                string[] ipAndPort = tempLine.Split(':');
-                                ipAddress = ipAndPort[0];
-                                port = int.Parse(ipAndPort[1]);
-                            }
-                            else if (tempLine.StartsWith("USN: uuid:"))
-                            {
-                                uniqueDeviceName = tempLine.Replace("USN: uuid:", "").Split(':')[0];
-                            }
-                        }
-                        //鍏抽棴娴�
-                        sr.Close();
-
-                        if (action != null)
-                        {
-                            if ("AllUniqueDeviceName" == uid)
-                            {
-                                action(new A31MusicModel { IPAddress = ipAddress, Port = port, Name = GetDeviceName(ipAddress, port), UniqueDeviceName = uniqueDeviceName });
-                            }
-                            else if (uid == uniqueDeviceName)
-                            {
-                                if (action != null)
-                                {
-                                    //琛ㄧず瀹屾垚浜�
-                                    action(null);
-                                }
-                                try
-                                {
-                                    udpClient.Close();
-                                    udpClient = null;
-                                }
-                                catch (Exception e) { System.Console.WriteLine(e.Message); }
-                                break;
-                            }
-                        }
-                    }
-                    catch (Exception e) { System.Console.WriteLine(e.Message); }
-                }
-            });
         }
         /// <summary>
-        /// 鏇存柊A31鎾斁鍣ㄧ殑鐘舵��
+        /// 鑾峰彇闊充箰鍒楄〃
         /// </summary>
-        /// <param name="a31MusicModel"></param>
-        public static void ReadStatus(A31MusicModel a31MusicModel)
+        public List<Function> GetMusicList
+        {
+            get
+            {
+                return FunctionList.List.GetMusicList();
+            }
+        }
+        /// <summary>
+        /// 鍙戦�佹帶鍒跺懡浠�
+        /// </summary>
+        /// <param name="function">褰撳墠璁惧</param>
+        /// <param name="dic">鍙戦�佹帶鍒舵暟鎹�</param>
+        public void SendControlCommand(Function function, Dictionary<string, string> dic)
+        {
+            new System.Threading.Thread(() =>
+            {
+                DriverLayer.Control.Ins.SendWriteCommand(function, dic);
+            })
+            { IsBackground = true }.Start();
+        }
+
+        /// <summary>
+        /// 鑾峰彇璁惧鏈�鏂扮殑鐘舵��
+        /// </summary>
+        /// <returns></returns>
+        public void GetDeviceStatus(ref A31MusicModel a31Music, List<string> functionIds, string sid)
         {
             try
             {
-                if (a31MusicModel.ServerClientType == 1)
-                {
-                    var result = OpenWeb("http://" + a31MusicModel.IPAddress + "/httpapi.asp?command=multiroom:getSlaveList");
-                    if (result != null && result != "Failed")
-                    {
-                        var slaves = Newtonsoft.Json.JsonConvert.DeserializeObject<Slaves>(result);
-                        if (slaves != null && slaves.slave_list != null && slaves.slave_list.Count != 0)
-                        {
-                            a31MusicModel.Slave = slaves;
-                        }
-                    }
-                }
-
-                WebClient webClient = new WebClient();
-                webClient.Headers.Add("Soapaction", "\"urn:schemas-upnp-org:service:AVTransport:1#GetInfoEx\"");
-                webClient.Headers.Add("CONTENT-TYPE", "text/xml; charset=\"utf-8\"");
-
-                var recevieBytes = webClient.UploadData(new Uri("http://" + a31MusicModel.IPAddress + ":" + a31MusicModel.Port + "/upnp/control/rendertransport1"), "POST", System.Text.Encoding.UTF8.GetBytes("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?><s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body><u:GetInfoEx xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID></u:GetInfoEx></s:Body></s:Envelope>"));
-                a31MusicModel.LastDateTime = DateTime.Now;//璁板綍鏁版嵁鍙嶉鐨勬椂闂�(鍥犱负鏈夋椂闂寸綉缁滃樊鏁版嵁涓嶅洖澶嶏紝瀵艰嚧褰撳墠鎾斁闊充箰鏃堕棿鏄剧ず涓嶆纭�)
-
-                var se = System.Security.SecurityElement.FromString(System.Text.Encoding.UTF8.GetString(recevieBytes)).SearchForChildByTag("s:Body").SearchForChildByTag("u:GetInfoExResponse");
-
-                if ("PLAYING" == se.SearchForTextOfTag("CurrentTransportState"))
-                {
-                    a31MusicModel.A31PlayStatus.status = "play";
-                }
-                else
-                {
-                    a31MusicModel.A31PlayStatus.status = "stop";
-                }
-                a31MusicModel.A31PlayStatus.totlen = (DateTime.Parse(se.SearchForTextOfTag("TrackDuration")) - DateTime.Parse("00:00:00")).TotalMilliseconds.ToString();
-
-                var trackMetaData = se.SearchForTextOfTag("TrackMetaData");
-                if (string.IsNullOrEmpty(trackMetaData))
+               // RefreshDeviceStatus(functionIds);
+                a31Music.LastDateTime = DateTime.Now;
+                ///浠庣紦瀛橀噷闈㈡煡鎵鹃煶涔愭挱鏀惧櫒瀵硅薄<缂撳瓨鏁版嵁鏀跺埌鎺ㄩ�佽繃鏉ョ殑鐘舵�佷細鏇存柊缂撳瓨鏁版嵁>
+                var allLocalFuntion = FunctionList.List.GetDeviceFunctionList();
+                var localFunction = allLocalFuntion.Find((obj) => obj.sid == sid);
+                if (localFunction == null)
                 {
                     return;
                 }
-                if (A31MusicModel.IsJson(trackMetaData))
-                {
-                    var a31QQSong = Newtonsoft.Json.JsonConvert.DeserializeObject<A31QQSong>(trackMetaData);
-                    a31MusicModel.A31PlayStatus.Title = a31QQSong.title;
-                    a31MusicModel.A31PlayStatus.Album = a31QQSong.album;
-                    a31MusicModel.A31PlayStatus.Artist = a31QQSong.creator;
-                }
-                else
-                {
-                    var metadata = trackMetaData.Replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "").Replace("&", "&amp;amp;");
-                    var item = SecurityElement.FromString(metadata).SearchForChildByTag("item");
-                    a31MusicModel.A31PlayStatus.Title = item.SearchForTextOfTag("dc:title");
-                    a31MusicModel.A31PlayStatus.Artist = item.SearchForTextOfTag("upnp:artist");
-                    a31MusicModel.A31PlayStatus.Album = item.SearchForTextOfTag("upnp:album");
-                }
-                a31MusicModel.A31PlayStatus.curpos = (DateTime.Parse(se.SearchForTextOfTag("RelTime")) - DateTime.Parse("00:00:00")).TotalMilliseconds.ToString();
-                a31MusicModel.A31PlayStatus.vol = se.SearchForTextOfTag("CurrentVolume");
-                a31MusicModel.A31PlayStatus.loop = se.SearchForTextOfTag("LoopMode");
-                a31MusicModel.A31PlayStatus.Source = se.SearchForTextOfTag("PlayMedium");
-                a31MusicModel.A31PlayStatus.playSource = se.SearchForTextOfTag("TrackSource");
-                a31MusicModel.A31PlayStatus.TrackURL = se.SearchForTextOfTag("TrackURI").Replace("&", "&amp;amp;"); 
+                ///鏇存柊鐨勬暟鎹�
+                a31Music.functionMusic = localFunction;
 
             }
-            catch (Exception ex)
-            {
-                Console.WriteLine(ex.Message);
-            }
-            finally
-            {
-                #region 鏇存柊鍏朵粬鐣岄潰闊充箰鐘舵��
-                Application.RunOnMainThread(() =>
-                {
-                    a31MusicModel.trait_on_off.curValue = a31MusicModel.A31PlayStatus.status == "play" ? "on" : "off";
-                    //Console.WriteLine($"music : {a31MusicModel.sid} : {a31MusicModel.on_off}");
-                    HomePage.UpdataFunctionStates(a31MusicModel);
-                    foreach (var e in A31MusicModel.A31MusicModelList)
-                    {
-                        RoomPage.UpdataStates(a31MusicModel);
-                    }
-                });
-                #endregion
-            }
+            catch { }
         }
 
-        public static string OpenWeb(string url)
-        {
-            try
-            {
-                var webClient = new WebClient();
-                return webClient.DownloadString(url);
-            }
-            catch (Exception e)
-            {
-                System.Console.WriteLine(e.Message);
-                return null;
-            }
-        }
         /// <summary>
-        /// 鑾峰彇A31鐨勫悕绉�
+        /// 鍒锋柊璁惧鐘舵��
         /// </summary>
-        /// <param name="ip"></param>
-        /// <param name="port"></param>
         /// <returns></returns>
-        static string GetDeviceName(string ip, int port)
+        public void RefreshDeviceStatus(List<string> functionIds)
         {
-            string deviceName = null;
-            System.IO.StreamReader sr = null;
-            WebClient webClient = new WebClient();
             try
             {
-                var receviceBytes = webClient.DownloadData(new Uri("http://" + ip + ":" + port + "/description.xml"));
-                sr = new System.IO.StreamReader(new System.IO.MemoryStream(receviceBytes), Encoding.UTF8);
-                string line = null;
-                string deviceType = null;
-
-                while ((line = sr.ReadLine()) != null)
+                Dictionary<string, object> d = new Dictionary<string, object>();
+                d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
+                d.Add("deviceIds", functionIds);
+                var responsePackNew = RequestServerhomeId(d, NewAPI.Api_Post_RefreshDeviceStatus);
+                if (responsePackNew.Code != "0" || responsePackNew.Data == null || responsePackNew.Data.ToString() == "")
                 {
-                    //System.Console.WriteLine (line);
-                    if (line.StartsWith("<friendlyName>"))
-                    {
-                        deviceName = line.Replace("<friendlyName>", "").Replace("</friendlyName>", "");
-                    }
-                    else if (line.StartsWith("<manufacturer>"))
-                    {
-                        deviceType = line.Replace("<manufacturer>", "").Replace("</manufacturer>", "");
-                    }
+                    return;
                 }
-                switch (deviceType)
-                {
-                    case "iEAST":
-                    case "Linkplay Technology Inc.":
-                        break;
-                    //涓嶆槸A31鐨勯煶涔愭暟鎹�
-                    default:
-                        deviceName = null;
-                        break;
-                }
-
-            }
-            catch (Exception e)
-            {
-                System.Console.WriteLine(e.Message);
-            }
-            finally
-            {
-                if (sr != null)
-                {
-                    sr.Close();
-                }
-            }
-            return deviceName;
-        }
-
-        /// <summary>
-        /// 鍒囨崲鎾斁鍣ㄦā寮�,淇敼闊充箰鍚嶇О,鍒囨崲钃濈墮,绾胯矾杈撳叆
-        /// </summary>
-        /// <param name="coutn"></param>
-        public static void SendCommand(string url)
-        {
-            System.Threading.Tasks.Task.Run(() =>
-            {
-                WebClient webClient = new WebClient();
-                try
-                {
-                    byte[] recevieBytes1 = webClient.DownloadData(new Uri(url));
-                }
-                catch (Exception ex)
-                {
-                    //this.IPAddress = ex.Message;
-                }
-            });
-        }
-        /// <summary>
-        /// 鎾斁
-        /// </summary>
-        public static void Play(A31MusicModel a31player)
-        {
-            System.Threading.Tasks.Task.Run(() =>
-            {
-                StringBuilder sb = new StringBuilder();
-                sb.AppendLine("<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">");
-                sb.AppendLine("<s:Body>");
-                sb.AppendLine("<u:Play xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\">");
-                sb.AppendLine("<InstanceID>0</InstanceID>");
-                sb.AppendLine("<Speed>1</Speed>");
-                sb.AppendLine("</u:Play>");
-                sb.AppendLine("</s:Body>");
-                sb.AppendLine("</s:Envelope>");
-
-                System.Net.WebClient webClient = new System.Net.WebClient();
-                webClient.Headers.Add("SOAPACTION", "\"urn:schemas-upnp-org:service:AVTransport:1#Play\"");
-                webClient.Headers.Add("CONTENT-TYPE", "text/xml; charset=\"utf-8\"");
-                try
-                {
-                    webClient.UploadData(new Uri("http://" + a31player.IPAddress + ":" + a31player.Port + "/upnp/control/rendertransport1"), "POST", Encoding.UTF8.GetBytes(sb.ToString()));
-                }
-                catch { }
-            });
-        }
-        /// <summary>
-        /// 鏆傚仠
-        /// </summary>
-        public static void Pause(A31MusicModel a31player)
-        {
-            System.Threading.Tasks.Task.Run(() =>
-            {
-                StringBuilder sb = new StringBuilder();
-                sb.AppendLine("<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">");
-                sb.AppendLine("<s:Body>");
-                sb.AppendLine("<u:Pause xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\">");
-                sb.AppendLine("<InstanceID>0</InstanceID>");
-                sb.AppendLine("</u:Pause>");
-                sb.AppendLine("</s:Body>");
-                sb.AppendLine("</s:Envelope>");
-
-                System.Net.WebClient webClient = new System.Net.WebClient();
-                webClient.Headers.Add("SOAPACTION", "\"urn:schemas-upnp-org:service:AVTransport:1#Pause\"");
-                webClient.Headers.Add("CONTENT-TYPE", "text/xml; charset=\"utf-8\"");
-                try
-                {
-                    webClient.UploadData(new Uri("http://" + a31player.IPAddress + ":" + a31player.Port + "/upnp/control/rendertransport1"), "POST", Encoding.UTF8.GetBytes(sb.ToString()));
-                }
-                catch { }
-            });
-
-        }
-        /// <summary>
-        /// 涓嬩竴鏇�
-        /// </summary>
-        public static void Next(A31MusicModel a31player)
-        {
-            System.Threading.Tasks.Task.Run(() =>
-            {
-                StringBuilder sb = new StringBuilder();
-                sb.AppendLine("<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">");
-                sb.AppendLine("<s:Body>");
-                sb.AppendLine("<u:Next xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\">");
-                sb.AppendLine("<InstanceID>0</InstanceID>");
-                sb.AppendLine("</u:Next>");
-                sb.AppendLine("</s:Body>");
-                sb.AppendLine("</s:Envelope>");
-
-                System.Net.WebClient webClient = new System.Net.WebClient();
-                webClient.Headers.Add("SOAPACTION", "\"urn:schemas-upnp-org:service:AVTransport:1#Next\"");
-                webClient.Headers.Add("CONTENT-TYPE", "text/xml; charset=\"utf-8\"");
-                try
-                {
-                    webClient.UploadData(new Uri("http://" + a31player.IPAddress + ":" + a31player.Port + "/upnp/control/rendertransport1"), "POST", Encoding.UTF8.GetBytes(sb.ToString()));
-                }
-                catch { }
-            });
-
-        }
-        /// <summary>
-        /// 涓婁竴鏇�
-        /// </summary>
-        public static void Previous(A31MusicModel a31player)
-        {
-            System.Threading.Tasks.Task.Run(() =>
-            {
-                StringBuilder sb = new StringBuilder();
-                sb.AppendLine("<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">");
-                sb.AppendLine("<s:Body>");
-                sb.AppendLine(" <u:Previous xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\">");
-                sb.AppendLine("<InstanceID>0</InstanceID>");
-                sb.AppendLine("</u:Previous>");
-                sb.AppendLine("</s:Body>");
-                sb.AppendLine("</s:Envelope>");
-
-                System.Net.WebClient webClient = new System.Net.WebClient();
-                webClient.Headers.Add("SOAPACTION", "\"urn:schemas-upnp-org:service:AVTransport:1#Previous\"");
-                webClient.Headers.Add("CONTENT-TYPE", "text/xml; charset=\"utf-8\"");
-                try
-                {
-                    webClient.UploadData(new Uri("http://" + a31player.IPAddress + ":" + a31player.Port + "/upnp/control/rendertransport1"), "POST", Encoding.UTF8.GetBytes(sb.ToString()));
-                }
-                catch { }
-            });
-
-        }
-        /// <summary>
-        /// 蹇繘
-        /// </summary>
-        public static void Seek(string seekvolume, A31MusicModel a31player)
-        {
-            System.Threading.Tasks.Task.Run(() =>
-            {
-                StringBuilder sb = new StringBuilder();
-                sb.AppendLine("<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">");
-                sb.AppendLine("<s:Body>");
-                sb.AppendLine(" <u:Seek xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\">");
-                sb.AppendLine("<InstanceID>0</InstanceID>");
-                sb.AppendLine("<Unit>REL_TIME</Unit>");
-                sb.AppendLine("<Target>" + seekvolume + "</Target>");
-                sb.AppendLine("</u:Seek>");
-                sb.AppendLine("</s:Body>");
-                sb.AppendLine("</s:Envelope>");
-
-                System.Net.WebClient webClient = new System.Net.WebClient();
-                webClient.Headers.Add("SOAPACTION", "\"urn:schemas-upnp-org:service:AVTransport:1#Seek\"");
-                webClient.Headers.Add("CONTENT-TYPE", "text/xml; charset=\"utf-8\"");
-                try
-                {
-                    webClient.UploadData(new Uri("http://" + a31player.IPAddress + ":" + a31player.Port + "/upnp/control/rendertransport1"), "POST", Encoding.UTF8.GetBytes(sb.ToString()));
-                }
-                catch { }
-            });
-        }
-        /// <summary>
-        /// 璋冭妭闊抽噺
-        /// </summary>
-        /// <param name="volume">Volume.</param>
-        public static void ControlVolume(int volume, A31MusicModel a31player)
-        {
-            System.Threading.Tasks.Task.Run(() => {
-                A31MusicModel.ProgressDateTime = DateTime.Now;
-                try
-                {
-                    if (a31player.ServerClientType == -1)
-                    {
-                        new System.Net.WebClient().DownloadData(new Uri("http://" + a31player.MainPlayIP + "/httpapi.asp?command=multiroom:SlaveVolume:" + a31player.IPAddress + ":" + volume));
-                    }
-                    else if (a31player.ServerClientType == 1)
-                    {
-                        new System.Net.WebClient().DownloadData(new Uri("http://" + a31player.IPAddress + "/httpapi.asp?command=setPlayerCmd:slave_vol:" + volume));
-                    }
-                    else
-                    {
-                        var sb = new StringBuilder();
-                        sb.AppendLine("<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">");
-                        sb.AppendLine("<s:Body>");
-                        sb.AppendLine("<u:SetVolume xmlns:u=\"urn:schemas-upnp-org:service:RenderingControl:1\">");
-                        sb.AppendLine("<InstanceID>0</InstanceID>");
-                        sb.AppendLine("<Channel>Master</Channel>");
-                        sb.AppendLine("<DesiredVolume>" + volume + "</DesiredVolume>");
-                        sb.AppendLine("</u:SetVolume>");
-                        sb.AppendLine("</s:Body>");
-                        sb.AppendLine("</s:Envelope>");
-
-                        var webClient = new System.Net.WebClient();
-                        webClient.Headers.Add("SOAPACTION", "\"urn:schemas-upnp-org:service:RenderingControl:1#SetVolume\"");
-                        webClient.Headers.Add("CONTENT-TYPE", "text/xml; charset=\"utf-8\"");
-                        webClient.UploadData(new Uri("http://" + a31player.IPAddress + ":" + a31player.Port + "/upnp/control/rendercontrol1"), "POST", Encoding.UTF8.GetBytes(sb.ToString()));
-                    }
-                }
-                catch { }
-            });
-
-        }
-        /// <summary>
-        /// 鑾峰彇USb鐨勫垪琛�
-        /// </summary>
-        public static List<MusicInfo> GetUsbList(A31MusicModel a31player)
-        {
-            var musicInfoList = new List<MusicInfo>();
-            musicInfoList.Clear();
-            var usbString = GetUSBPlayList(a31player);
-            if (usbString == null)
-            {
-                return musicInfoList;
-            }
-            var se = System.Security.SecurityElement.FromString(usbString);
-            if (se == null)
-            {
-                return musicInfoList;
-            }
-            while (se.Children != null)
-            {
-                se = se.Children[0] as System.Security.SecurityElement;
-            }
-
-            foreach (SecurityElement track in SecurityElement.FromString(se.Text).SearchForChildByTag("Tracks").Children)
-            {
-                MusicInfo musicInfo = new MusicInfo();
-                musicInfo.URL = track.SearchForTextOfTag("URL").Replace("&", "&amp;amp;");
-                var metadata = track.SearchForTextOfTag("Metadata").Replace("&", "&amp;");
-                var item = SecurityElement.FromString(metadata).SearchForChildByTag("item");
-                musicInfo.Title = item.SearchForTextOfTag("dc:title").Replace("&", "&amp;amp;"); 
-                musicInfo.Artist = item.SearchForTextOfTag("upnp:artist").Replace("&", "&amp;amp;");
-                musicInfo.Album = item.SearchForTextOfTag("upnp:album").Replace("&", "&amp;amp;");
-                musicInfo.Duration = item.SearchForTextOfTag("res");
-                musicInfo.AlbumId = item.SearchForTextOfTag("song:albumid").Replace("&", "&amp;amp;");
-                musicInfoList.Add(musicInfo);
-            }
-            return musicInfoList;
-        }
-        /// <summary>
-        ///璇锋眰USB鍒楄〃鍛戒护
-        /// </summary>
-        public static string GetUSBPlayList(A31MusicModel a31player)
-        {
-
-            StringBuilder getPlayList = new StringBuilder();
-            getPlayList.AppendLine("<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">");
-            getPlayList.AppendLine("<s:Body>");
-            getPlayList.AppendLine("<u:BrowseQueue xmlns:u=\"urn:schemas-wiimu-com:service:PlayQueue:1\">");
-            getPlayList.AppendLine("<QueueName>USBDiskQueue</QueueName>");
-            getPlayList.AppendLine("</u:BrowseQueue>");
-            getPlayList.AppendLine("</s:Body>");
-            getPlayList.AppendLine("</s:Envelope>");
-
-            WebClient webClient = new WebClient();
-            webClient.Headers.Add("SOAPACTION", "\"urn:schemas-wiimu-com:service:PlayQueue:1#BrowseQueue\"");
-            webClient.Headers.Add("CONTENT-TYPE", "text/xml; charset=\"utf-8\"");
-
-            try
-            {
-                byte[] recevieBytes = webClient.UploadData(new Uri("http://" + a31player.IPAddress + ":" + a31player.Port + "/upnp/control/PlayQueue1"), "POST", System.Text.Encoding.UTF8.GetBytes(getPlayList.ToString()));
-                return System.Text.Encoding.UTF8.GetString(recevieBytes, 0, recevieBytes.Length);
-            }
-            catch { }
-
-            return null;
-        }
-
-        /// <summary>
-        /// 璇诲彇鐢靛彴缁勫垪琛�
-        /// </summary>
-        /// <returns>璇诲彇鍒扮殑鐢靛彴缁勫垪琛ㄤ俊鎭紝璇诲彇涓嶅埌鍙嶉涓簄ull</returns>
-        public static string ReadRadioList(string url)
-        {
-            WebClient webClient = new WebClient();
-            webClient.Proxy = null;
-            webClient.Headers.Add("Content-type", "plain/text; charset=UTF-8");
-            if (Language.CurrentLanguage == "Chinese")
-            {
-                webClient.Headers.Add("Accept-Language", "zh-cn");
-            }
-            else
-            {
-                webClient.Headers.Add("Accept-Language", "en-us");
-            }
-            try
-            {
-                byte[] recevieBytes = webClient.DownloadData(new Uri(url));
-                return System.Text.Encoding.UTF8.GetString(recevieBytes, 0, recevieBytes.Length);
-
-            }
-            catch (Exception e)
-            {
-                return null;
-            }
-
-        }
-
-        /// <summary>
-        /// 鑾峰彇褰撳墠鎾斁鐨勫垪琛�
-        /// </summary>
-        public static  string GetCurrentPlayList(A31MusicModel a31player)
-        {
-            System.Text.StringBuilder getPlayList = new System.Text.StringBuilder();
-            getPlayList.AppendLine("<?xml version=\"1.0\"encoding=\"utf-8\"?>");
-            getPlayList.AppendLine("<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">");
-            getPlayList.AppendLine("<s:Body>");
-            getPlayList.AppendLine("<u:BrowseQueue xmlns:u=\"urn:schemas-wiimu-com:service:PlayQueue:1\">");
-            getPlayList.AppendLine("<QueueName>CurrentQueue</QueueName>");
-            getPlayList.AppendLine("</u:BrowseQueue>");
-            getPlayList.AppendLine("</s:Body>");
-            getPlayList.AppendLine("</s:Envelope>");
-
-            System.Net.WebClient webClient = new System.Net.WebClient();
-            webClient.Headers.Add("SOAPACTION", "\"urn:schemas-wiimu-com:service:PlayQueue:1#BrowseQueue\"");
-            webClient.Headers.Add("CONTENT-TYPE", "text/xml; charset=\"utf-8\"");
-            try
-            {
-                byte[] recevieBytes = webClient.UploadData(new Uri("http://" + a31player.IPAddress + ":" + a31player.Port + "/upnp/control/PlayQueue1"), "POST", System.Text.Encoding.UTF8.GetBytes(getPlayList.ToString()));
-                return System.Text.Encoding.UTF8.GetString(recevieBytes, 0, recevieBytes.Length);
-            }
-            catch { }
-            return null;
-        }
-        /// <summary>
-        /// 鎾斁USB闊充箰鍛戒护
-        /// </summary>
-        /// <param name="listName">鍒楄〃鍚嶇О</param>
-        /// <param name="number">鎾斁绱㈠紩</param>
-        public static void ListMusicPlay(string listName, object number, A31MusicModel a31player)
-        {
-            System.Text.StringBuilder playstrings = new System.Text.StringBuilder();
-            playstrings.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>");
-            playstrings.AppendLine("<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">");
-            playstrings.AppendLine("<s:Body>");
-            playstrings.AppendLine("<u:PlayQueueWithIndex xmlns:u=\"urn:schemas-wiimu-com:service:PlayQueue:1\">");
-            playstrings.AppendLine("<QueueName>" + listName + "</QueueName>");
-            playstrings.AppendLine("<Index>" + number + "</Index>");
-            playstrings.AppendLine("</u:PlayQueueWithIndex>");
-            playstrings.AppendLine("</s:Body>");
-            playstrings.AppendLine("</s:Envelope>");
-            System.Net.WebClient webClient = new System.Net.WebClient();
-            webClient.Headers.Add("SOAPACTION", "\"urn:schemas-wiimu-com:service:PlayQueue:1#PlayQueueWithIndex\"");
-            webClient.Headers.Add("CONTENT-TYPE", "text/xml; charset=\"utf-8\"");
-            try
-            {
-                byte[] recevieBytes = webClient.UploadData(new Uri("http://" + a31player.IPAddress + ":" + a31player.Port + "/upnp/control/PlayQueue1"), "POST", Encoding.UTF8.GetBytes(playstrings.ToString()));
-                var s = System.Text.Encoding.UTF8.GetString(recevieBytes, 0, recevieBytes.Length);
             }
             catch { }
         }
 
 
+        /// <summary>
+        /// 璁惧鍚嶇О淇敼
+        /// </summary>
+        public string EditDeviceName(string deviceId, string deviceName)
+        {
+            Dictionary<string, object> d = new Dictionary<string, object>();
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
+            d.Add("deviceId", deviceId);
+            d.Add("name", deviceName);
+
+            var requestJson = HttpUtil.GetSignRequestJson(d);
+            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_EditDeviceName, requestJson).Code;
+        }
 
         /// <summary>
-        /// 鎺ㄩ�佹挱鏀惧懡浠�
+        /// 鑾峰彇闊充箰鍒楄〃
         /// </summary>
-        /// <param name="musicInfo">鎾斁闊充箰</param>
-        /// <param name="listName">鍒楄〃鍚嶇О</param>
-        /// <param name="musicList">鎺ㄩ�佸垪琛�(榛樿鎺�50棣�)</param>
-        public  static void PushList(MusicInfo musicInfo, string listName, List<MusicInfo> musicList, A31MusicModel a31player,string musicSource)
+        /// <param name="music"></param>
+        /// <returns></returns>
+        public void GetPalyList(Function music)
         {
-
-            //鏈�澶у彂閫佺殑鏉℃暟
-            int maxCount = 50;
-            //鎵惧嚭褰撳墠鐐瑰嚮闊充箰鐨勭储寮�
-            int statIndex = musicList.FindIndex((obj) => { return obj == musicInfo; });
-            //鐐瑰嚮鍚庨潰杩樻湁澶氬皯鏉¢煶涔�
-            int count = musicList.Count - statIndex;
-            int endIndex = 0;
-            if (maxCount < count)
-            {
-                //濡傛灉鍚庨潰鐨勯煶涔愬ぇ浜庢渶澶ф暟锛岃缃悗闈㈡暟鎹殑鏈�澶х储寮� 
-                endIndex = statIndex + maxCount - 1;
-            }
-            else
-            {
-                //濡傛灉鍚庨潰鏁版嵁涓嶅锛屽氨鐢ㄦ�绘暟鍑忓幓鏈�澶ф潯鏁帮紝寰楀埌寮�濮嬬储寮�
-                statIndex = musicList.Count - maxCount - 1;
-                endIndex = musicList.Count - 1;
-            }
-            //濡傛灉寮�濮嬬储寮曞皬浜�0锛岄偅灏辫缃负绗竴鏉¢煶涔�
-            if (statIndex < 0)
-            {
-                statIndex = 0;
-            }
-
-            StringBuilder sb = new StringBuilder();
-            sb.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
-            sb.AppendLine("<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">");
-            sb.AppendLine("<s:Body>");
-            sb.AppendLine("<u:CreateQueue xmlns:u=\"urn:schemas-wiimu-com:service:PlayQueue:1\">");
-            sb.AppendLine("<QueueContext>&lt;?xml version=\"1.0\"?&gt;");
-            sb.AppendLine("&lt;PlayList&gt;");
-            sb.AppendLine("&lt;ListName&gt;DLNA" + listName + "&lt;/ListName&gt;");
-            sb.AppendLine("&lt;ListInfo&gt;");
-            sb.AppendLine("&lt;Radio&gt;0&lt;/Radio&gt;");//
-            sb.AppendLine("&lt;SourceName&gt;UPnPServer&lt;/SourceName&gt;");//          
-            sb.AppendLine("&lt;MarkSearch&gt;0&lt;/MarkSearch&gt;");
-            sb.AppendLine("&lt;TrackNumber&gt;" + (endIndex - statIndex + 1) + "&lt;/TrackNumber&gt;");
-            sb.AppendLine("&lt;Quality&gt;0&lt;/Quality&gt;");
-            sb.AppendLine("&lt;UpdateTime&gt;5367&lt;/UpdateTime&gt;");
-            sb.AppendLine("&lt;LastPlayIndex&gt;2&lt;/LastPlayIndex&gt;");
-            sb.AppendLine("&lt;SwitchPageMode&gt;0&lt;/SwitchPageMode&gt;");
-            sb.AppendLine("&lt;CurrentPage&gt;0&lt;/CurrentPage&gt;");
-            sb.AppendLine("&lt;TotalPages&gt;0&lt;/TotalPages&gt;");
-            sb.AppendLine("&lt;/ListInfo&gt;");
-            sb.AppendLine("&lt;Tracks&gt;");
-
-            int number = 1;
-
-            for (int i = statIndex, Tracknumber = 1; i <= endIndex; i++, Tracknumber++)
-            {
-                var tempMusicInfo = musicList[i];
-
-                if (musicInfo == tempMusicInfo)
-                {
-                    number = Tracknumber;
-                }
-
-                if (tempMusicInfo.SourceType == "Local")
-                {
-                    tempMusicInfo.URL = "http://" + new Shared.Net.NetWiFi().IpAddress + ":" + com.hdl.on.Server.Port + "/" + tempMusicInfo.ID;
-                }
-
-                sb.AppendLine("&lt;Track" + Tracknumber + "&gt;");
-                sb.AppendLine("&lt;URL&gt;" + tempMusicInfo.URL + "&lt;/URL&gt;");
-                sb.AppendLine("&lt;Metadata&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;");
-                sb.AppendLine("&amp;lt;DIDL-Lite xmlns:dc=&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot; xmlns:upnp=&amp;quot;urn:schemas-upnp-org:metadata-1-0/upnp/&amp;quot; xmlns:song=&amp;quot;www.wiimu.com/song/&amp;quot; xmlns=&amp;quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&amp;quot;&amp;gt;");
-                sb.AppendLine("&amp;lt;upnp:class&amp;gt;object.item.audioItem.musicTrack&amp;lt;/upnp:class&amp;gt;");
-                sb.AppendLine("&amp;lt;item id=&amp;quot;0&amp;quot;&amp;gt;");
-                sb.AppendLine("&amp;lt;song:subid&amp;gt;&amp;lt;/song:subid&amp;gt;");
-                sb.AppendLine("&amp;lt;song:description&amp;gt;unknown&amp;lt;/song:description&amp;gt;");
-                sb.AppendLine("&amp;lt;song:skiplimit&amp;gt;6&amp;lt;/song:skiplimit&amp;gt;");
-                sb.AppendLine("&amp;lt;song:id&amp;gt;" + tempMusicInfo.ID + "&amp;lt;/song:id&amp;gt;");
-                sb.AppendLine("&amp;lt;song:like&amp;gt;0&amp;lt;/song:like&amp;gt;");
-                sb.AppendLine("&amp;lt;song:singerid&amp;gt;0&amp;lt;/song:singerid&amp;gt;");
-                sb.AppendLine("&amp;lt;song:albumid&amp;gt;" + tempMusicInfo.AlbumId + "&amp;lt;/song:albumid&amp;gt;");
-
-                sb.AppendLine("&amp;lt;res protocolInfo=&amp;quot;http-get:*:audio/mpeg:DLNA.ORG_PN=MP3;DLNA.ORG_OP=01;&amp;quot; duration=&amp;quot;" + "0:0:0.0" + "&amp;quot;&amp;gt;" + tempMusicInfo.URL + "&amp;lt;/res&amp;gt;");
-
-                sb.AppendLine("&amp;lt;dc:title&amp;gt;" + tempMusicInfo.Title + "&amp;lt;/dc:title&amp;gt;");
-                sb.AppendLine("&amp;lt;dc:creator&amp;gt;DJ Sanny J&amp;lt;/dc:creator&amp;gt;");
-                if (musicSource== "鎴戠殑鍒楄〃") {
-                    sb.AppendLine("&amp;lt;upnp:artist&amp;gt;" + listName + "&amp;lt;/upnp:artist&amp;gt;");
-                }
-                else {
-                    sb.AppendLine("&amp;lt;upnp:artist&amp;gt;" + tempMusicInfo.Artist + "&amp;lt;/upnp:artist&amp;gt;");
-                }
-                sb.AppendLine("&amp;lt;upnp:album&amp;gt;" + tempMusicInfo.Album + "&amp;lt;/upnp:album&amp;gt;");
-                sb.AppendLine("&amp;lt;upnp:albumArtURI&amp;gt;unknown&amp;lt;/upnp:albumArtURI&amp;gt;");
-                sb.AppendLine("&amp;lt;/item&amp;gt;");
-                sb.AppendLine("&amp;lt;/DIDL-Lite&amp;gt;");
-                sb.AppendLine("&lt;/Metadata&gt;");
-                sb.AppendLine("&lt;Id&gt;" + tempMusicInfo.ID + "&lt;/Id&gt;");
-                sb.AppendLine("&lt;Source&gt;STATION-NETWORK&lt;/Source&gt;");//UPnPServer
-                sb.AppendLine("&lt;Key&gt;" + tempMusicInfo.URL + "&lt;/Key&gt;");
-                sb.AppendLine("&lt;/Track" + Tracknumber + "&gt;");
-            }
-            sb.AppendLine("&lt;/Tracks&gt;");
-            sb.AppendLine("&lt;/PlayList&gt;");
-            sb.AppendLine("</QueueContext>");
-            sb.AppendLine("</u:CreateQueue>");
-            sb.AppendLine("</s:Body>");
-            sb.AppendLine("</s:Envelope>");
-
-            SendMusicLists(a31player.IPAddress, a31player.Port, "CreateQueue", sb.ToString());
-
-            StringBuilder playString = new StringBuilder();
-            playString.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
-            playString.AppendLine("<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">");
-            playString.AppendLine("<s:Body>");
-            playString.AppendLine("<u:PlayQueueWithIndex xmlns:u=\"urn:schemas-wiimu-com:service:PlayQueue:1\">");
-            playString.AppendLine("<QueueName>DLNA" + listName + "</QueueName>");
-            playString.AppendLine("<Index>" + number + "</Index>");
-            playString.AppendLine("</u:PlayQueueWithIndex>");
-            playString.AppendLine("</s:Body>");
-            playString.AppendLine("</s:Envelope>");
-
-            Play(a31player.IPAddress, a31player.Port, playString.ToString());
-        }
-
-       static void SendMusicLists(string ip, int port, string soapAction, string listInfo)
-        {
-            System.Net.WebClient webClient = new System.Net.WebClient();
-            webClient.Headers.Add("SOAPACTION", "\"urn:schemas-wiimu-com:service:PlayQueue:1#" + soapAction + "\"");
-            webClient.Headers.Add("CONTENT-TYPE", "text/xml; charset=\"utf-8\"");
             try
             {
-                byte[] recevieBytes = webClient.UploadData(new Uri("http://" + ip + ":" + port + "/upnp/control/PlayQueue1"), "POST", System.Text.Encoding.UTF8.GetBytes(listInfo));
-                var s = System.Text.Encoding.UTF8.GetString(recevieBytes, 0, recevieBytes.Length);
-            }
-            catch(Exception e)
-            {
-                var d = e.Message;
-            }
-        }
-
-       static void Play(string ip, int port, string info)
-        {
-            System.Net.WebClient webClient = new System.Net.WebClient();
-            webClient.Headers.Add("SOAPACTION", "\"urn:schemas-wiimu-com:service:PlayQueue:1#PlayQueueWithIndex\"");
-            webClient.Headers.Add("CONTENT-TYPE", "text/xml; charset=\"utf-8\"");
-            try
-            {
-                byte[] recevieBytes = webClient.UploadData(new Uri("http://" + ip + ":" + port + "/upnp/control/PlayQueue1"), "POST", System.Text.Encoding.UTF8.GetBytes(info));
-                var s = System.Text.Encoding.UTF8.GetString(recevieBytes, 0, recevieBytes.Length);
+                Dictionary<string, object> d = new Dictionary<string, object>();
+                d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
+                d.Add("deviceIds", new List<string> { music.deviceId });
+                var responsePackNew = RequestServerhomeId(d, NewAPI.Api_Post_PlayerList);
+                if (responsePackNew.Code != "0"||responsePackNew.Data == null ||responsePackNew.Data.ToString() == "")
+                {
+                    return;
+                }
+                //鏁版嵁杩斿簭鍒楀寲涓篎unction瀵硅薄
+                var str = Newtonsoft.Json.JsonConvert.SerializeObject(responsePackNew.Data);
+                var palyLists = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PalyListInfo>>(str);
+                if (palyLists == null)
+                {
+                    palyLists =new List<PalyListInfo>();
+                }
+                if (palyLists.Count > 0)
+                {
+                    ///榛樿鎷跨涓�涓垪琛�
+                    A31MusicModel.Current.palyLists = palyLists[0].playlist;
+                }
             }
             catch
             {
-
             }
+
         }
-
-
-
-        static System.Threading.Thread thread;
+       
         /// <summary>
-        /// 淇敼钃濈墮鍚嶇О
+        ///璇锋眰鏈嶅姟鍣紙涓庝綇瀹呮湁鍏�:渚嬪锛沨omeId锛� 
         /// </summary>
-        /// <param name="message"></param>
-        public static void ModifyBluetoothName(string message)
+        /// <returns></returns>
+        public  ResponsePackNew RequestServerhomeId(object o, string api_Url, int mTimeout = 5)
         {
-            if (thread != null)
-            {
-                thread.Abort();
-            }
-            thread = new System.Threading.Thread(() =>
-            {
-                var tcpClient = new TcpClient() { ReceiveTimeout = 1000 };
-                try
-                {
-                    //杩涜杩炴帴
-                    tcpClient.Connect(new IPEndPoint(IPAddress.Parse(A31MusicModel.Current.IPAddress), 8899));
-                    var buffter = Encoding.UTF8.GetBytes(message);
-                    var sendByes = new byte[20 + buffter.Length];
-                    sendByes[0] = 0x18;
-                    sendByes[1] = 0x96;
-                    sendByes[2] = 0x18;
-                    sendByes[3] = 0x20;
+            var requestJson = HttpUtil.GetSignRequestJson(o);
+            return HttpUtil.RequestHttpsPostFroHome(api_Url, requestJson, mTimeout);
 
-                    sendByes[4] = (byte)((buffter.Length & 0x000000FF) >> 0);
-                    sendByes[5] = (byte)((buffter.Length & 0x0000FF00) >> 8);
-                    sendByes[6] = (byte)((buffter.Length & 0x00FF0000) >> 16);
-                    sendByes[7] = (byte)((buffter.Length & 0xFF000000) >> 24);
-
-                    var checkSum = getCheckSum(buffter);
-                    sendByes[8] = (byte)((checkSum & 0x000000FF) >> 0);
-                    sendByes[9] = (byte)((checkSum & 0x0000FF00) >> 8);
-                    sendByes[10] = (byte)((checkSum & 0x00FF0000) >> 16);
-                    sendByes[11] = (byte)((checkSum & 0xFF000000) >> 24);
-
-                    sendByes[16] = 0x08;
-
-                    Array.Copy(buffter, 0, sendByes, 20, buffter.Length);
-                    tcpClient.GetStream().Write(sendByes, 0, sendByes.Length);
-                    tcpClient.GetStream().Flush();
-
-                    thread = null;
-                }
-                catch { }
-                finally
-                {
-                    tcpClient.Close();
-                }
-            });
-            thread.Start();
         }
-        static uint getCheckSum(byte[] buffer)
-        {
-            uint check_sum = 0;
-
-            for (int i = 0; i < buffer.Length; i++)
-            {
-                check_sum += buffer[i];
-            }
-
-            return check_sum;
-        }
-        public class A31QQSong
-        {
-            public string title = string.Empty;
-            public string album = string.Empty;
-            public string creator = string.Empty;
-        }
-
     }
 }

--
Gitblit v1.8.0