private void ProcessOrderChangeMessage(OrderChangeMessage message) { ChangeMessage <OrderMarketChange> change = ChangeMessageFactory.ToChangeMessage(message); change = OrderSubscriptionHandler.ProcessChangeMessage(change); if (change != null) { ChangeHandler.OnOrderChange(change); } }
/// <summary> /// Process a line of json /// </summary> /// <exception cref="JsonException">Thrown if line was invalid json</exception> /// <param name="line"></param> public ResponseMessage ReceiveLine(string line) { //clear last response ResponseMessage message = null; LastResponseTime = DateTime.UtcNow; var time = Stopwatch.StartNew(); string operation = GetOperation(new JsonTextReader(new StringReader(line))); switch (operation) { case RESPONSE_CONNECTION: Trace.TraceInformation("ESA->Client: {0}", line); ConnectionMessage connectionMessage = ReadResponseMessage <ConnectionMessage>(line); message = connectionMessage; ProcessConnectionMessage(connectionMessage); break; case RESPONSE_STATUS: Trace.TraceInformation("ESA->Client: {0}", line); StatusMessage statusMessage = ReadResponseMessage <StatusMessage>(line); message = statusMessage; ProcessStatusMessage(statusMessage); break; case RESPONSE_MARKET_CHANGE_MESSAGE: TraceChange(line); MarketChangeMessage marketChangeMessage = ReadResponseMessage <MarketChangeMessage>(line); message = marketChangeMessage; ProcessMarketChangeMessage(marketChangeMessage); break; case RESPONSE_ORDER_CHANGE_MESSAGE: TraceChange(line); OrderChangeMessage orderChangeMessage = ReadResponseMessage <OrderChangeMessage>(line); message = orderChangeMessage; ProcessOrderChangeMessage(orderChangeMessage); break; default: Trace.TraceError("ESA->Client: Unknown message type: {0}, message:{1}", operation, line); break; } time.Stop(); return(message); }
public static ChangeMessage <OrderMarketChange> ToChangeMessage(OrderChangeMessage message) { ChangeMessage <OrderMarketChange> change = new ChangeMessage <OrderMarketChange>() { Id = (int)message.Id, Pt = message.Pt, Clk = message.Clk, InitialClk = message.InitialClk, ConflateMs = message.ConflateMs, HeartbeatMs = message.HeartbeatMs, }; change.Items = message.Oc; switch (message.SegmentType) { case OrderChangeMessage.SegmentTypeEnum.SegStart: change.SegmentType = SegmentType.SEG_START; break; case OrderChangeMessage.SegmentTypeEnum.SegEnd: change.SegmentType = SegmentType.SEG_END; break; case OrderChangeMessage.SegmentTypeEnum.Seg: change.SegmentType = SegmentType.SEG; break; } switch (message.Ct) { case OrderChangeMessage.CtEnum.Heartbeat: change.ChangeType = ChangeType.HEARTBEAT; break; case OrderChangeMessage.CtEnum.ResubDelta: change.ChangeType = ChangeType.RESUB_DELTA; break; case OrderChangeMessage.CtEnum.SubImage: change.ChangeType = ChangeType.SUB_IMAGE; break; } return(change); }