public override void FilterWrite(INextFilter nextFilter, IoSession session, IWriteRequest writeRequest)
            {
                AbstractIoSession s = session as AbstractIoSession;

                if (s != null)
                {
                    // Maintain counters.
                    IoBuffer buffer = writeRequest.Message as IoBuffer;
                    if (buffer != null)
                    {
                        // I/O processor implementation will call buffer.Reset()
                        // it after the write operation is finished, because
                        // the buffer will be specified with messageSent event.
                        buffer.Mark();
                        Int32 remaining = buffer.Remaining;
                        if (remaining == 0)
                        {
                            // Zero-sized buffer means the internal message delimiter
                            s.IncreaseScheduledWriteMessages();
                        }
                        else
                        {
                            s.IncreaseScheduledWriteBytes(remaining);
                        }
                    }
                    else
                    {
                        s.IncreaseScheduledWriteMessages();
                    }
                }

                IWriteRequestQueue writeRequestQueue = session.WriteRequestQueue;

                if (session.WriteSuspended)
                {
                    writeRequestQueue.Offer(session, writeRequest);
                }
                else if (writeRequestQueue.IsEmpty(session))
                {
                    // We can write directly the message
                    session.Processor.Write(session, writeRequest);
                }
                else
                {
                    writeRequestQueue.Offer(session, writeRequest);
                    session.Processor.Flush(session);
                }
            }
Ejemplo n.º 2
0
        public void Write(SocketSession session, IWriteRequest writeRequest)
        {
            IWriteRequestQueue writeRequestQueue = session.WriteRequestQueue;

            writeRequestQueue.Offer(session, writeRequest);
            if (!session.WriteSuspended)
            {
                Flush(session);
            }
        }
Ejemplo n.º 3
0
        private void Write(SerialSession session, IWriteRequest writeRequest)
        {
            IWriteRequestQueue writeRequestQueue = session.WriteRequestQueue;

            writeRequestQueue.Offer(session, writeRequest);
            if (!session.WriteSuspended)
            {
                Flush(session);
            }
        }
Ejemplo n.º 4
0
 /// <inheritdoc/>
 public void Offer(IoSession session, IWriteRequest writeRequest)
 {
     _queue.Offer(session, writeRequest);
 }