public void HandleFileUpdate(MessageDetails des)
 {
     _avventoApi.FileDownloads.ReceivedFileUpdatesCallback(des, true);
 }
        public void Handler()
        {
            while (!receiveQueue.IsCompleted)
            {
                ConnectionData packet = receiveQueue.Take();
                MessageDetails des    = new MessageDetails(packet);
                _avventoApi.InternalEvents.APIRAWMessageReceived?.Invoke(des);
                switch (des.headerType)
                {
                case MessageType.MESSAGE_1_LOGIN_REPLY:
                {
                    LoginReply loginReply = Utilities.OnPacket <LoginReply>(des.data);

                    _avventoApi.IncomingMessages.ReceivedLoginReplyCallback(loginReply);
                }
                break;

                case MessageType.MESSAGE_10_OUTGOING_HEARTBEAT_GENERATOR:
                {
                    _avventoApi.IncomingMessages.ReceivedHeartbeatCallback();
                }
                break;

                case MessageType.MESSAGE_16_ENCRYPTIONKEY_RESPONSE:
                {
                    _avventoApi.IncomingMessages.EncryptionKey(des, des.data);
                }
                break;

                case MessageType.MESSAGE_36_START_OF_DAY_DOWNLOAD:
                {
                    HandleFileDownloadChunk(des);
                }
                break;

                case MessageType.MESSAGE_123_FILE_UPDATE:
                {
                    HandleFileDownloadChunk(des);
                    HandleFileUpdate(des);
                }
                break;

                case MessageType.MESSAGE_125_EXCHANGEANNOUCEMENT:
                {
                    ExchangeAnnouncementStructure announcement = Utilities.OnPacket <ExchangeAnnouncementStructure>(des.data);
                    _avventoApi.FileDownloads.ExchangeAnnouncement(announcement, ActionType.Insert);
                }
                break;

                case MessageType.MESSAGE_126_ORDERREJECTMESSAGE:
                {
                    OrderRejectMessage orm = Utilities.OnPacket <OrderRejectMessage>(des.data);
                    _avventoApi.IncomingMessages.OrderReject(orm);
                }
                break;

                case MessageType.MESSAGE_59_SCREEN_UPDATE_REPLY:
                {
                    //get the depth structure first
                    Depth depth = (Depth)DataConverter.ConvertFromBufferToStruct(des.data, 1, Depth.Length, typeof(Depth));         //skip the first byte as it only used when processing 99s

                    //get the underlying depth elements
                    int    calcedLengthElements = Marshal.SizeOf <DepthElement>() * depth.Header.NumDepth;
                    byte[] depthElements        = new byte[calcedLengthElements];
                    Buffer.BlockCopy(depth.DepthElements, 0, depthElements, 0, calcedLengthElements);


                    List <DepthElement> elements = DataConverter.ConvertFromBufferToStructList <DepthElement>(depthElements, Marshal.SizeOf <DepthElement>());

                    _avventoApi.IncomingMessages.ReceivedDisplayUpdateCallback(elements);
                }
                break;

                case MessageType.MESSAGE_132_BUSINESSMESSAGEREJECT:
                {
                    BusinessRejectStructure bmr = Utilities.OnPacket <BusinessRejectStructure>(des.data);
                    _avventoApi.IncomingMessages.BusinessMessageReject(bmr);
                }
                break;

                case MessageType.MESSAGE_133_ORDERCANCELREJECT:
                {
                    OrderCancelRejectStructure ocr = Utilities.OnPacket <OrderCancelRejectStructure>(des.data);
                    _avventoApi.IncomingMessages.OrderCancelReject(ocr);
                }
                break;

                default:
                    log.Warn($"Unknown message type: {des.headerType}");
                    break;
                }
            }
        }