Ejemplo n.º 1
0
        // Make a copy of message for task handler.
        // If pktLen!=0, sets idx and copy pktLen to that.
        // Returns new index if successful.
        int CopyMessage(int idx, byte pktLen)
        {
            int ioIndex = Manager.IoBuffersFreeHeap.Allocate();

            if (ioIndex != -1)
            {
                PacketBuffer a = Manager.IoBuffers[idx];
                PacketBuffer b = Manager.IoBuffers[ioIndex];
                if (pktLen == 0)
                {
                    pktLen = (byte)(ProtocolConstants.GENERAL_OVERHEADS_SIZE + a.dataLength());
                }
                else
                {
                    a.pktLen = pktLen;
                }
                b.meta(a);
                Array.Copy(a.buffer, 0, b.buffer, 0, pktLen);
            }
            return(ioIndex);
        }