Exemple #1
0
        private bool AddPage()
        {
            if (!_packetProviders.ContainsKey(StreamSerial))
            {
                if (_ignoredSerials.Contains(StreamSerial))
                {
                    // nevermind... we're supposed to ignore these
                    return(false);
                }

                var packetProvider = new LightPacketProvider(this);
                _packetProviders.Add(StreamSerial, packetProvider);
                if (!_newStreamCallback(packetProvider))
                {
                    _packetProviders.Remove(StreamSerial);
                    _ignoredSerials.Add(StreamSerial);
                    packetProvider.Dispose();
                    return(false);
                }
            }
            else
            {
                _packetProviders[StreamSerial].AddPage();
            }

            return(true);
        }
Exemple #2
0
 internal LightPacket(LightPageReader reader, LightPacketProvider packetProvider, int index, IList <Tuple <long, int> > data)
     : base(data.Sum(p => p.Item2))
 {
     _reader         = reader;
     _packetProvider = packetProvider;
     Index           = index;
     _dataSrc        = data;
 }
Exemple #3
0
        private bool NewStreamCallback(LightPacketProvider packetProvider)
        {
            var relock = _reader.Release();
            var ea     = new NewStreamEventArgs(packetProvider);

            try
            {
                NewStream?.Invoke(this, ea);
            }
            finally
            {
                if (relock)
                {
                    _reader.Lock();
                }
            }
            return(!ea.IgnoreStream);
        }