private void btSearch_Click(object sender, EventArgs e) { localIpSet.Clear(); IPHostEntry ipe = Dns.GetHostEntry(Dns.GetHostName()); foreach (var ip in ipe.AddressList) { localIpSet.Add(ip.ToString()); } udpClient = new XingKongUtils.UdpUtils.UdpSend("255.255.255.255", 9849); udpClient.message(BROADCAST_SEARCH_DEVICE); }
private void UdpClient_DataReceived2(byte[] data, System.Net.IPEndPoint addrSource) { if (data.Length == 4) { Keys key = (Keys)BitConverter.ToInt32(data, 0); Console.WriteLine(string.Format("Key:{0} Pressed.", key.ToString())); KeyPressed?.Invoke(key); } else if (data.Length == 3) { XingKongUtils.UdpUtils.UdpSend udpSend = new XingKongUtils.UdpUtils.UdpSend(addrSource.Address.ToString(), 9850); udpSend.message(RETURN_BROADCAST_IP_ADDRESS); Console.WriteLine("Broadcast Received."); } }
public void MusicInfoReceived(MusicInfo mi) { //Console.WriteLine(mi.Name); //Console.WriteLine(mi.Singer); //Console.WriteLine(mi.Album); //Console.WriteLine(mi.picBase64); udpsend = new XingKongUtils.UdpUtils.UdpSend(tcpListener.RemoteIp.ToString(), 7777);//每次建立连接后都重新初始化一下udp对象 lbName.Text = mi.Name; lbSinger.Text = mi.Singer; lbAlbum.Text = mi.Album; if (!string.IsNullOrWhiteSpace(mi.picBase64)) { pbAlbum.LoadPicture(ToImage(mi.picBase64)); } XingKongScreen.ClearScreen(); currentWindow.HardworkDraw(); XingKongScreen.FreshScreen(); }
private void btConnect_Click(object sender, EventArgs e) { udpClient = new XingKongUtils.UdpUtils.UdpSend(cbIpList.Text, 9849); }