示例#1
0
        private void OnBroadcastReceived(IAsyncResult asyn)
        {
            try
            {
                Packet socketData = (Packet)asyn.AsyncState;
                int    dataSize   = socketData.CurrentSocket.EndReceive(asyn);

                OnReceiveBroadcast?.Invoke(socketData.DataBuffer, dataSize);

                WaitForBroadcast();
            }

            catch (ObjectDisposedException)
            {
                System.Console.WriteLine("Client EXCEPTION in OnBroadcastReceived: Socket has been closed");
            }

            catch (SocketException se)
            {
                System.Console.WriteLine("Client EXCEPTION in OnBroadcastReceived: " + se.Message);
            }
        }
示例#2
0
 void IHostListener.OnHostReceiveBroadcast(IPEndPoint remote, Reader message)
 {
     OnReceiveBroadcast?.Invoke(remote, message);
 }