public async Task Run()
        {
            UdpLaserListener.Status = true;


            while (UdpLaserListener.Status)
            {
                this.udpClient = new UdpClient(port);
                this.groupEP   = new IPEndPoint(IPAddress.Loopback.Address, port);

                try
                {
                    byte[] bytes = await Task <byte[]> .Factory.StartNew(() =>
                    {
                        Console.WriteLine("Waiting for broadcast");
                        return(udpClient.Receive(ref groupEP));
                    });

                    IncomingData?.Invoke(this, bytes);
                }
                catch (SocketException er)
                {
                    Console.WriteLine(er);
                }
                finally
                {
                    udpClient.Close();
                }
            }
            udpClient.Close();
        }
        private void _OnDataReceived(object sender, Renci.SshNet.Common.ShellDataEventArgs e)
        {
            string input = Encoding.UTF8.GetString(e.Data);

            if (IncomingData != null)
            {
                IncomingData.Invoke(this, new IncomingDataEventArgs {
                    Data = input
                });
            }
        }
Beispiel #3
0
        public string RX()
        {
            var sb = new System.Text.StringBuilder();

            while (!Buffer_RX.Empty)
            {
                sb.Append(Buffer_RX.Dequeue);
            }

            Console.WriteLine($"[RX] :{sb.ToString()}#");
            IncomingData?.Invoke(this, EventArgs.Empty);

            return(sb.ToString());
        }
 protected virtual void OnDataReceived(DataReceived eventArgs)
 {
     IncomingData?.Invoke(this, eventArgs);
 }
Beispiel #5
0
 private void onIncomingData(object o)
 {
     IncomingData?.Invoke(this, new ObjectEventArgs(o));
 }