private unsafe void SubscriptionReply(LimeQuoteMessage message) { LimeQuotesInterop.subscription_reply_msg *subReply = (LimeQuotesInterop.subscription_reply_msg *)message.Ptr; if (subReply->outcome != LimeQuotesInterop.subscription_outcome.SUBSCRIPTION_SUCCESSFUL) { log.ErrorFormat("Subscription request failed: error code {0}", subReply->outcome.ToString()); } else { log.InfoFormat("Subscription started"); } }
private unsafe void SymbolRequest(LimeQuoteMessage message) { LimeQuotesInterop.subscription_request_msg *subRequest = (LimeQuotesInterop.subscription_request_msg *)message.Ptr; String symbol = ""; for (int i = 0; subRequest->syb_symbols[i] != 0; i++) { symbol += (char)subRequest->syb_symbols[i]; } var symbolInfo = Factory.Symbol.LookupSymbol(symbol); log.Info("Lime: Received symbol request for " + symbolInfo); ProviderSimulator.AddSymbol(symbolInfo.Symbol); var writePacket = (LimeQuoteMessage)QuoteSocket.MessageFactory.Create(); LimeQuotesInterop.subscription_reply_msg *reply = (LimeQuotesInterop.subscription_reply_msg *)writePacket.Ptr; reply->msg_type = LimeQuotesInterop.limeq_message_type.SUBSCRIPTION_REPLY; var msg_len = (ushort)sizeof(LimeQuotesInterop.subscription_reply_msg); reply->msg_len = Reverse(msg_len); writePacket.Length = msg_len; reply->outcome = LimeQuotesInterop.subscription_outcome.SUBSCRIPTION_SUCCESSFUL; for (int i = 0; i < 4; i++) { reply->qsid[i] = subRequest->qsid[i]; } QuotePacketQueue.Enqueue(writePacket, message.SendUtcTime); var bookRebuildMessage = (LimeQuoteMessage)QuoteSocket.MessageFactory.Create(); LimeQuotesInterop.book_rebuild_msg *book = (LimeQuotesInterop.book_rebuild_msg *)bookRebuildMessage.Ptr; book->msg_type = LimeQuotesInterop.limeq_message_type.BOOK_REBUILD; msg_len = (ushort)sizeof(LimeQuotesInterop.book_rebuild_msg); book->msg_len = Reverse(msg_len); bookRebuildMessage.Length = msg_len; book->symbol_index = (uint)symbolInfo.BinaryIdentifier; for (int i = 0; i < symbol.Length; i++) { book->symbol[i] = (byte)symbol[i]; } QuotePacketQueue.Enqueue(bookRebuildMessage, message.SendUtcTime); }