Esempio n. 1
0
        internal virtual bool postClose(int priority)
        {
            bool result;
            IList <OutgoingFrame> tail = null;

            lock (outgoingFrames)
            {
                if (outgoingFrames.Count == 0)
                {
                    // there are no outgoing frames,
                    // the channel can be closed immediately
                    result = true;
                }
                else
                {
                    OutgoingFrame poisonPill =
                        new OutgoingFrame(
                            null, 0, 0, 0, null, 0, 0, 0, true
                            );

                    int insertionIndex =
                        findOutgoingInsertionIndex(priority);
                    outgoingFrames.Insert(insertionIndex, poisonPill);
                    tail = cleanOutgoingFrames(insertionIndex + 1);

                    result = false;
                }
            }

            if (result == false)
            {
                // notify cancellation for those messages
                // that are behind the poison pill
                // (they will be never transmitted)

                notifyCancellation(tail);
            }

            return(result);
        }
Esempio n. 2
0
        internal virtual void post(int transportId, int priority,
                                   IList <byte[]> buffers, int messageHeaderSize,
                                   MessageProgressCallback messageProgressCallback)
        {
            // add new buffers to the queue of outgoing frames
            const bool closeFlag      = false;
            int        byteCount      = 0;
            int        totalByteCount = 0;

            foreach (byte[] buf in buffers)
            {
                totalByteCount += buf.Length;
            }

            lock (outgoingFrames)
            {
                // find the proper place to insert into the queue
                int insertionIndex = findOutgoingInsertionIndex(priority);

                int frameNumber = 1;
                foreach (byte[] buf in buffers)
                {
                    byteCount += buf.Length;
                    if (frameNumber == buffers.Count)
                    {
                        // the frame number is negative for the last frame
                        frameNumber *= -1;
                    }

                    OutgoingFrame newFrame = new OutgoingFrame(
                        buf, transportId, frameNumber,
                        messageHeaderSize, messageProgressCallback,
                        byteCount, totalByteCount, priority, closeFlag);

                    outgoingFrames.Insert(insertionIndex++, newFrame);

                    ++frameNumber;
                }
            }
        }
Esempio n. 3
0
        internal virtual bool postClose(int priority)
        {
            bool result;
            IList<OutgoingFrame> tail = null;
            lock (outgoingFrames)
            {
                if (outgoingFrames.Count == 0)
                {
                // there are no outgoing frames,
                // the channel can be closed immediately
                    result = true;
                }
                else
                {
                    OutgoingFrame poisonPill =
                        new OutgoingFrame(
                            null, 0, 0, 0, null, 0, 0, 0, true
                            );

                    int insertionIndex =
                        findOutgoingInsertionIndex(priority);
                    outgoingFrames.Insert(insertionIndex, poisonPill);
                    tail = cleanOutgoingFrames(insertionIndex + 1);

                    result = false;
                }
            }

            if (result == false)
            {
            // notify cancellation for those messages
            // that are behind the poison pill
            // (they will be never transmitted)

                notifyCancellation(tail);
            }

            return result;
        }
Esempio n. 4
0
        internal virtual void post(int transportId, int priority, 
            IList<byte[]> buffers, int messageHeaderSize, 
            MessageProgressCallback messageProgressCallback)
        {
            // add new buffers to the queue of outgoing frames
            const bool closeFlag = false;
            int byteCount = 0;
            int totalByteCount = 0;
            foreach (byte[] buf in buffers)
            {
                totalByteCount += buf.Length;
            }

            lock (outgoingFrames)
            {
            // find the proper place to insert into the queue
                int insertionIndex = findOutgoingInsertionIndex(priority);

                int frameNumber = 1;
                foreach (byte[] buf in buffers)
                {
                    byteCount += buf.Length;
                    if (frameNumber == buffers.Count)
                    {
                    // the frame number is negative for the last frame
                        frameNumber *= -1;
                    }

                    OutgoingFrame newFrame = new OutgoingFrame(
                        buf, transportId, frameNumber,
                        messageHeaderSize, messageProgressCallback,
                        byteCount, totalByteCount, priority, closeFlag);

                    outgoingFrames.Insert(insertionIndex++, newFrame);

                    ++frameNumber;
                }
            }
        }