From 5efaaab958a0f4a91ad9d76b5d5fea0ea3fc3f41 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期二, 01 十二月 2020 16:24:19 +0800 Subject: [PATCH] 2020-12-01 1.请求路径修改。 2.切换住宅或者查询住宅列表增加获取网关列表。 3.房间增加默认图片选择、比例调整为16:9。4.优化图片裁剪。 --- HDL_ON/DAL/DriverLayer/UdpSocket.cs | 33 +++++++++++++++++++-------------- 1 files changed, 19 insertions(+), 14 deletions(-) diff --git a/HDL_ON/DAL/DriverLayer/UdpSocket.cs b/HDL_ON/DAL/DriverLayer/UdpSocket.cs index 2af43f3..376e6bb 100644 --- a/HDL_ON/DAL/DriverLayer/UdpSocket.cs +++ b/HDL_ON/DAL/DriverLayer/UdpSocket.cs @@ -1,9 +1,8 @@ 锘縰sing System; using System.Net.Sockets; using System.Net; -using Newtonsoft.Json.Linq; -namespace HDL_ON +namespace HDL_ON.DriverLayer { public class UdpSocket { @@ -22,20 +21,29 @@ //鏈湴Socket private Socket busSocket; - + int _port = 0; /// <summary> /// 鍚姩Socket鎺ユ敹鍜屽彂閫佸姛鑳� /// </summary> - public void Start () + public void Start (int port) { - if (IsRunning ) { - return; - } + if (IsRunning) + { + if (port == _port) + { + return; + } + else + { + busSocket.Close(); + } + } + _port = port; busSocket = new Socket (AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); busSocket.EnableBroadcast = true; try { - busSocket.Bind (new IPEndPoint (IPAddress.Any, 6000)); + busSocket.Bind (new IPEndPoint (IPAddress.Any, port)); busSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(IPAddress.Parse("239.0.168.188"))); } @@ -46,7 +54,7 @@ asyncBeginReceive(); - MainPage.Log ($"udp port : 6000"); + MainPage.Log ($"udp port : {port}"); } /// <summary> @@ -98,10 +106,6 @@ Console.WriteLine($"asyncBeginReceive {e.Message}"); } } - /// <summary> - /// 鎼滅储缃戠粶璁惧瑙﹀彂鐨勫洖璋冧簨浠� - /// </summary> - public Action<string> SearchNetDeviceAction; /// <summary> /// 寮傛鎺ユ敹鏁版嵁缁撴潫 @@ -124,10 +128,11 @@ packet.Bytes = new byte[len]; Array.Copy(bytes, 0, packet.Bytes, 0, packet.Bytes.Length); + //MainPage.Log($"鎺ユ敹{packet.RemoteEndPoint}鏁版嵁"); //mqtt杩炴帴鏁版嵁璇诲彇 A鍗忚缃戠粶璁惧淇℃伅璇诲彇鍥炲 澶勭悊 if (((IPEndPoint)packet.RemoteEndPoint).Port == 8585) { - Common.A_Protocal_Common.apc.ConvertReceiveData(bytes); + Control.Ins.ConvertReceiveData(bytes); } else if(((IPEndPoint)packet.RemoteEndPoint).Port == 6000)//澶勭悊bus 6000绔彛鐨勬暟鎹� { -- Gitblit v1.8.0