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); } }
void IHostListener.OnHostReceiveBroadcast(IPEndPoint remote, Reader message) { OnReceiveBroadcast?.Invoke(remote, message); }