Exemple #1
0
        private void TestDecoderAndInputStream(String expected, IoBuffer input)
        {
            // Test ProtocolDecoder
            IProtocolDecoder       decoder    = new ObjectSerializationDecoder();
            ProtocolCodecSession   session    = new ProtocolCodecSession();
            IProtocolDecoderOutput decoderOut = session.DecoderOutput;

            decoder.Decode(session, input.Duplicate(), decoderOut);

            Assert.AreEqual(1, session.DecoderOutputQueue.Count);
            Assert.AreEqual(expected, session.DecoderOutputQueue.Dequeue());
        }
        private void InternalFlush(INextFilter nextFilter, IoSession session, IoBuffer buf)
        {
            IoBuffer tmp = null;

            lock (buf)
            {
                buf.Flip();
                tmp = buf.Duplicate();
                buf.Clear();
            }
            if (log.IsDebugEnabled)
            {
                log.Debug("Flushing buffer: " + tmp);
            }
            nextFilter.FilterWrite(session, new DefaultWriteRequest(tmp));
        }
Exemple #3
0
        /// <inheritdoc/>
        public IEnumerable <IWriteFuture> Broadcast(Object message)
        {
            List <IWriteFuture> answer = new List <IWriteFuture>(_managedSessions.Count);
            IoBuffer            buf    = message as IoBuffer;

            if (buf == null)
            {
                foreach (var session in _managedSessions.Values)
                {
                    answer.Add(session.Write(message));
                }
            }
            else
            {
                foreach (var session in _managedSessions.Values)
                {
                    answer.Add(session.Write(buf.Duplicate()));
                }
            }
            return(answer);
        }
 protected override Boolean DoDecode(IoSession session, IoBuffer input, IProtocolDecoderOutput output)
 {
     input.Duplicate(); // Will disable auto-expansion.
     Assert.IsFalse(input.AutoExpand);
     return(base.DoDecode(session, input, output));
 }