Ejemplo n.º 1
0
        public void DataReceived(IAsyncResult ar)
        {
            //Console.WriteLine("DataReceived!");
            byte[] data = _udpClient.EndReceive(ar, ref _udpEndpoint);

            _resetEvent.Set();

            DataPiece dataPiece = new DataPiece(data);

            _announcer.AnnounceData(dataPiece);
        }
Ejemplo n.º 2
0
        private void Listen()
        {
            while (true)
            {
                _resetEvent.Reset();
                UdpState state = new UdpState();
                state.e = _udpEndpoint;
                state.u = _udpClient;

                //Console.WriteLine("Listening");
                //_udpClient.BeginReceive(new AsyncCallback(DataReceived), null);

                //_resetEvent.WaitOne();

                byte[] data = _udpClient.Receive(ref _udpEndpoint);

                DataPiece dataPiece = new DataPiece(data);
                _announcer.AnnounceData(dataPiece);
            }
        }
Ejemplo n.º 3
0
 public void AnnounceData(DataPiece data)
 {
     dataHandlers.ForEach(handler => handler.HandleData(data));
 }