public UdpSocketClientPage()
        {
            _client = new UdpSocketClient();
            _messagesSub = new Subject<Message>();
            _messagesObs = _messagesSub.AsObservable();

            InitView();
        }
Example #2
0
 public async Task Send(byte[] data, int bytes, IPEndPoint remoteHost)
 {
     var client = new UdpSocketClient();
     await client.SendToAsync(data, remoteHost.Address, remoteHost.Port);
     System.Console.WriteLine(System.DateTime.Now.ToString() + ">>> " + remoteHost);
     System.Console.WriteLine(FormatterHelper.Deserialize(data).ToString());
     System.Console.WriteLine();
 }
Example #3
0
        public async static Task SendDataAsync(string host, int port, List<byte[]> datas, int delay = 100)
        {
            
            UdpSocketClient socket = new UdpSocketClient();
            SemaphoreSlim sendlock = GetLock(host);

            if (sendlock != null) await sendlock.WaitAsync();
            try
            {
                int i = 0;
                foreach (byte[] data in datas)
                {
                    i++;
                    await socket.SendToAsync(data, host, port);
                    if (delay > 0 && datas.Count != i) await Task.Delay(delay);
                }                

            }
            catch (Exception ex)
            {
                _2BDebug.Output(ex);                
            }
            
            if (sendlock != null)  sendlock.Release();
           

            socket.Dispose();
        }