Esempio n. 1
0
 /// <summary>
 /// 当属性改变时,调用Udp发送功能
 /// </summary>
 private void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == nameof(AltViewModel.Readout))
     {
         Sender?.SendAsync($"Gps={Gps.Readout}");
     }
 }
 private async Task Send(byte[] data, Player player)
 {
     if (player.IPTo != null)
     {
         await UdpSender.SendAsync(data, data.Length, player.IPTo);
     }
 }
Esempio n. 3
0
        static void Main(string[] args)
        {
            var sender = new UdpSender();

            Logger.Enable(Loggers.ConsoleLogger);
            bool stop = false;

            do
            {
                string input = Console.ReadLine();
                sender.SendAsync(input);
                stop = input == "s";
            } while (!stop);
        }
        public void OnSend(object sender, EventDataArg <string> e)
        {
            Logger.Info($"Send to {e.HostInfo.Host} via {e.HostInfo.Protocol} message {e.Data}");
            switch (e.HostInfo.Protocol)
            {
            case UdpSender.Name:
                UdpSender.SendAsync(e.HostInfo.Host, e.Data);
                break;

            case TcpSender.Name:
                TcpSender.SendAsync(e.HostInfo.Host, e.Data);
                break;

            default:
                Logger.Error($"Unknow protocol {e.HostInfo.Protocol} for {e.HostInfo}, message {e.Data}");
                break;
            }
        }