예제 #1
0
        private void storeOrDispatchCurrentFrame()
        {
            if (currentIncomingFrameNumber == -1)
            {
                // typical case:
                // this is a single-frame message and it is complete

                dispatchShortMessage(currentIncomingFrame.data);
            }
            else
            {
                // this is a multi-frame message
                IncomingMessageFrames messageFrames = null;
                if (!incomingFrames.ContainsKey(
                        currentIncomingFrameTransportId))
                {
                    messageFrames = new IncomingMessageFrames();
                    incomingFrames.Add(
                        currentIncomingFrameTransportId, messageFrames);
                }
                else
                {
                    messageFrames =
                        incomingFrames[currentIncomingFrameTransportId];
                }

                bool messageIsComplete = messageFrames.accumulate(
                    currentIncomingFrameNumber,
                    currentIncomingMessageHeaderSize,
                    currentIncomingFrame);

                if (messageIsComplete)
                {
                    // collect all frames together

                    IList <byte[]> headerBuffers = new List <byte[]>();
                    IList <byte[]> bodyBuffers   = new List <byte[]>();

                    messageFrames.getAllBuffers(headerBuffers, bodyBuffers);

                    // the frame manager for this message is no longer needed
                    incomingFrames.Remove(currentIncomingFrameTransportId);

                    dispatch(headerBuffers, bodyBuffers);
                }
            }
        }
예제 #2
0
        private void storeOrDispatchCurrentFrame()
        {
            if (currentIncomingFrameNumber == -1)
            {
            // typical case:
            // this is a single-frame message and it is complete

                dispatchShortMessage(currentIncomingFrame.data);

            }
            else
            {
            // this is a multi-frame message
                IncomingMessageFrames messageFrames = null;
                if(!incomingFrames.ContainsKey(
                    currentIncomingFrameTransportId))
                {
                    messageFrames = new IncomingMessageFrames();
                    incomingFrames.Add(
                        currentIncomingFrameTransportId, messageFrames);
                }
                else
                {
                    messageFrames =
                        incomingFrames[currentIncomingFrameTransportId];
                }

                bool messageIsComplete = messageFrames.accumulate(
                    currentIncomingFrameNumber,
                    currentIncomingMessageHeaderSize,
                    currentIncomingFrame);

                if (messageIsComplete)
                {

                // collect all frames together

                    IList<byte[]> headerBuffers = new List<byte[]>();
                    IList<byte[]> bodyBuffers = new List<byte[]>();

                    messageFrames.getAllBuffers(headerBuffers, bodyBuffers);

                // the frame manager for this message is no longer needed
                    incomingFrames.Remove(currentIncomingFrameTransportId);

                    dispatch(headerBuffers, bodyBuffers);
                }
            }
        }