private void ProcessByRecieveHandler(int code, BinaryReader reader, IRecieveHandler handler) { Log.Debug($"Handler found - {handler}"); var postProcessedMessage = handler.HandleResponce(code, reader); if (postProcessedMessage == null) { return; } try { ProcessReceivedMessage(postProcessedMessage); } catch (Exception ex) { Log.Error("Cannot process message", ex); } }
public void StartRecieve(IRecieveHandler handler) { var endpointGroup = new IPEndPoint(IPAddress.Any, (int)Port); // @@ idkkkk try { while (IsRunning) { byte[] byteStream = UdpInstance.Receive(ref endpointGroup); byte[] handlerOutput = handler.Invoke(byteStream); // @@ this should be elsewhere? UdpInstance.Send(handlerOutput, handlerOutput.Length, endpointGroup); Debug.WriteLine("Udp Server is now free!"); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }