private void WriteForQuotation() { Token token; TraderState state = SessionManager.Default.GetTokenAndState(this._Id, out token); if (state == null || token == null) { Write(); return; } this._QuotationQueue.Clear(); this._QuotationQueue.Add(this._CurrentCommand.Quotation.QuotationCommand); while (this._Queue.Count > 0) { CommandForClient item = this._Queue.Peek(); if (item.CommandType != DataType.Quotation) { break; } item = this._Queue.Dequeue(); this._QuotationQueue.Add(item.Quotation.QuotationCommand); } byte[] content; if (this._QuotationQueue.Count == 1) { content = this._CurrentCommand.Quotation.GetPriceInBytes(token, state); } else { QuotationCommand command = new QuotationCommand(); command.Merge(this._QuotationQueue); content = QuotationTranslator.GetPriceInBytes(token, state, command, this._QuotationQueue[0].Sequence, this._QuotationQueue[this._QuotationQueue.Count - 1].Sequence); } if (content == null) { Write(); return; } this._CurrentPacket = SerializeManager.Default.SerializePrice(content); this.BeginWrite(this._CurrentPacket, 0, this._CurrentPacket.Length); }
public CommandForClient(UnmanagedMemory data = null, QuotationCommand quotationCommand = null, Command command = null) { if (command != null) { this._Command = command; this._Quotation = null; this._Data = null; this._CommandType = DataType.Command; } else if (quotationCommand != null) { this._Quotation = new QuotationTranslator(quotationCommand); this._Command = null; this._Data = null; this._CommandType = DataType.Quotation; } else { this._Data = data; this._Command = null; this._Quotation = null; this._CommandType = DataType.Response; } }