Esempio n. 1
0
 private void UdpSend(string msg)
 {
     if (udpsend != null)
     {
         udpsend.message(Encoding.UTF8.GetBytes(msg));
     }
 }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 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.");
     }
 }
Esempio n. 4
0
 private void sendKey(Keys key)
 {
     byte[] data = BitConverter.GetBytes((int)key);
     udpClient.message(data);
 }