private void StartListen() { string ipStr = IPtb.Text; IPAddress ip; if (!string.IsNullOrEmpty(ipStr) && !string.IsNullOrEmpty(Porttb.Text)) { try { int portStr = Convert.ToInt32(Porttb.Text); if (IPAddress.TryParse(ipStr, out ip)) { ludp2 = new LightUDP(ip, portStr); //建立UDP 监听端口 ludp2.AutoEcho = true; ludp2.DGramRecieved += new DGramRecievedHandle(ludp2_DGramRecieved); // SendMessage("发送") ; //暂时不需要发送功能; } else { MessageBox.Show("IP格式有误"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
internal void StartListen() { //var servers = archorList.ServerList; //foreach (var server in servers) //{ // var localIp = IpHelper.GetLocalIp(server.Ip); // if (localIp != null && localIp.Address.ToString() == server.Ip) // { // LightUDP udp = new LightUDP(server.Ip, server.Port); // udp.DGramRecieved += Udp_DGramRecieved1; // serverUdps.Add(udp); // } //} string[] ips = new string[] { "192.168.3.253", "192.168.4.253", "192.168.5.253" }; foreach (var ip in ips) { var localIp = IpHelper.GetLocalIp(ip); if (localIp != null && localIp.ToString() == ip) { LightUDP udp = new LightUDP(ip, 1998); udp.DGramRecieved += Udp_DGramRecieved1; serverUdps.Add(udp); } } }
private void InitSendAlarmUdp() { if (ludpSendAlarm == null) { Log.Info(LogTags.Engine, "PositionEngineDA.InitSendAlarmUdp"); ludpSendAlarm = LightUDP.Create(IPAddress.Parse(Login.LocalIp), Login.LocalPort2); //建立UDP 监听端口 } }
private void StopListen() { if (ludp2 != null) { ludp2.Close(); ludp2 = null; } }
private void InitUdp() { if (ludp2 == null) { Log.Info(LogTags.Engine, "PositionEngineDA.InitUdp"); ludp2 = LightUDP.Create(IPAddress.Parse(Login.LocalIp), Login.LocalPort); //建立UDP 监听端口 //ludp2.DGramRecieved += Ludp2_DGramRecieved; ludp2.DGramListRecieved += Ludp2_DGramListRecieved; } }
private void BtnGet_Click(object sender, RoutedEventArgs e) { var ip = TbIP.Text; if (udp1 == null) { var ipLocal = IpHelper.GetLocalIp(ip); udp1 = new LightUDP(ipLocal, 1111); udp1.DGramRecieved += Udp_DGramRecieved; } var tmp = UDPCommands.GetServerIp; udp1.SendHex(tmp, new IPEndPoint(IPAddress.Parse(ip), 4646)); }
private void BtnSet_Click(object sender, RoutedEventArgs e) { var ip = TbIP.Text; if (udp2 == null) { var ipLocal = IpHelper.GetLocalIp(ip); udp2 = new LightUDP(ipLocal, 1112); udp2.DGramRecieved += Udp_DGramRecieved; } var tmp = TbValue.Text;//10 01 C0 03 00 A4 FC C2 79 udp2.SendHex(tmp, new IPEndPoint(IPAddress.Parse(ip), 4646)); }
private LightUDP GetLightUDP(IPAddress localIp) { LightUDP udp = null; var id = localIp.ToString(); if (udps.ContainsKey(id)) { udp = udps[id]; } else { udp = new LightUDP(localIp, 1111); udp.DGramRecieved += Udp_DGramRecieved; udps[id] = udp; } return(udp); }
private string SendPos(Position pos) { if (pos == null) { return(""); } string txt = pos.GetText(LocationContext.OffsetX, LocationContext.OffsetY, 0); if (udp == null) { udp = new LightUDP("127.0.0.1", 5678); } udp.Send(txt, "127.0.0.1", 2323); return(txt); //return ""; }
private void BtnStart_Click(object sender, RoutedEventArgs e) { var ip = CbIps.Text; var port = TbPort.Text; if (BtnStart.Content.ToString() == "开始") { udp = LightUDP.Create(ip, port.ToInt()); udp.DGramRecieved += Udp_DGramRecieved; BtnStart.Content = "停止"; } else { udp.Close(); BtnStart.Content = "开始"; } }
public LightUDP GetLightUDP(IPAddress localIp) { count++; LightUDP udp = null; var id = localIp.ToString(); if (udps.ContainsKey(id)) { udp = udps[id]; } else { udp = LightUDP.Create(localIp, port + count); udp.DGramRecieved += Udp_DGramRecieved; udps[id] = udp; } return(udp); }
private void BtnGet_Click(object sender, RoutedEventArgs e) { try { var ip = TbIP.Text; if (udp1 == null) { var ipLocal = IpHelper.GetLocalIp(ip); udp1 = LightUDP.Create(ipLocal, 1111); udp1.DGramRecieved += Udp_DGramRecieved; } var tmp = UDPCommands.GetServerIp; udp1.SendHex(tmp, new IPEndPoint(IPAddress.Parse(ip), 4646)); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public void Stop() { try { if (aliveThread != null) { aliveThread.Abort(); aliveThread = null; } if (ludp2 != null) { ludp2.Close(); ludp2 = null; } } catch (Exception ex) { Log.Error("PositionEngineDA.Stop", ex); } }
private void BtnSet_Click(object sender, RoutedEventArgs e) { try { var ip = TbIP.Text; if (udp2 == null) { var ipLocal = IpHelper.GetLocalIp(ip); udp2 = LightUDP.Create(ipLocal, 1112); udp2.DGramRecieved += Udp_DGramRecieved; } var tmp = TbValue.Text;//10 01 C0 03 00 A4 FC C2 79 udp2.SendHex(tmp, new IPEndPoint(IPAddress.Parse(ip), 4646)); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public void Start(IPAddress localIP, int localPort) { udp = LightUDP.Create(localIP, localPort); udp.DGramRecieved += Udp_DGramRecieved; }