Exemplo n.º 1
0
        public bool TrySplit(MemoryStream other)
        {
            bool split = false;

            if (other.Length > 3)
            {
                long position = other.Position;
                //ushort length = (ushort)(other.ReadByte() | other.ReadByte() << 8);

                ushort length = (ushort)(((ushort)other.ReadByte() << 8) | other.ReadByte());
                other.Position = position;
                if (other.Length >= position + length)
                {
                    if (length >= MaxMessageSize)
                    {
                        log.WarnFormat("Lime Message of {0} bytes is larger the max message size of {1}.  Buffer reallocated", length, MaxMessageSize);
                        // Build a new message buffer with a little room to spare.
                        BuildMessageBuffer(length + 128, true);
                    }
                    split   = true;
                    _Length = length;
                    _Data.SetLength(_Length);
                    _Data.Position = 0;

                    // Read must be last as SetLength clears the buffer :(
                    other.Read(_MessageBuffer, 0, length);
                    if (trace)
                    {
                        LimeQuotesProvider.LogMessage(Ptr, log);
                    }
                }
            }
            return(split);
        }
        //internal static TimeStamp SimulatorTime = new TimeStamp(0L);

        public LimeQuotesProvider(string name)
            : base(name)
        {
            provider = this;
            log.Register(this);
            if (name.Contains(".config"))
            {
                throw new ApplicationException("Please remove .config from config section name.");
            }
            RetryStart    = 1;
            RetryIncrease = 1;
            RetryMaximum  = 30;
            if (SyncTicks.Enabled)
            {
                HeartbeatDelay = int.MaxValue;
            }
            else
            {
                HeartbeatDelay = 10;
            }
            log.InfoFormat("Constructed LimeQuotesProvider( {0} )", name);
        }