public void SignalOnNext(Tuple <string, Signal> signal) { var source = signal.Item1; switch (signal.Item2.Type) { case SignalType.TradeSignal: var sign = ProtoExtension.DeSerialize <MT4TradeSignal>(signal.Item2.Content); if (TradeSignals != null) { TradeSignals(new Tuple <string, MT4TradeSignal>(source, sign)); } break; case SignalType.SignalOrdersStatus: var stats = ProtoExtension.DeSerialize <OrdersStatusResponse>(signal.Item2.Content); if (OrdersStatus != null) { OrdersStatus(new Tuple <string, OrdersStatusResponse>(source, stats)); } break; case SignalType.ConnectSignal: SignalService.Logger.Info("Connect signal received"); break; default: throw new ArgumentOutOfRangeException(); } }
private void RouterOnReceiveReady(object sender, NetMQSocketEventArgs netMqSocketEventArgs) { try { var socket = netMqSocketEventArgs.Socket; var message = socket.ReceiveMessage(); var clientId = Encoding.UTF8.GetString(message.First.Buffer); var mess = message.Last.Buffer; var signal = ProtoExtension.DeSerialize <Signal>(mess); if (signal != null) { if (signal.Type == SignalType.ConnectSignal) { SignalService.Logger.Info("Connect message from client {0} ", clientId); SendConnectedMessage(socket, clientId); } if (Signals != null) { Signals((new Tuple <string, Signal>(clientId, signal))); } } } catch (Exception ex) { SignalService.Logger.Error("Error: {0}", ex.Message); } }