Example #1
0
        private BaseResponse ParseRawData(ByteBuffer buf)
        {
            MessageType msgType;

            try
            {
                msgType = (MessageType)lastHeader.msgId;
            }
            catch
            {
                return(null);
            }

            BaseResponse resp = null;

            if (msgType == MessageType.RejectResponse)
            {
                resp = RejectResponse.ReadFromBuffer(lastHeader, buf, offset);
            }

            else if (msgType == MessageType.NewOrderReport)
            {
                resp = OrderResponse.ReadFromBuffer(lastHeader, buf, offset);
            }

            else if (msgType == MessageType.CancelReport)
            {
                resp = CancelOrderResponse.ReadFromBuffer(lastHeader, buf, offset);
            }

            else if (msgType == MessageType.ExecutionReport)
            {
                resp = ExecutionReport.ReadFromBuffer(lastHeader, buf, offset);
            }

            else if (msgType == MessageType.MassCancelReport)
            {
                resp = MassCancelResponse.ReadFromBuffer(lastHeader, buf, offset);
            }

            if (resp != null)
            {
                if (!messagesParsedByType.TryGetValue(resp.GetType(), out var count))
                {
                    messagesParsedByType.Add(resp.GetType(), 1);
                }
                else
                {
                    messagesParsedByType[resp.GetType()] = count + 1;
                }
            }

            return(resp);
        }