コード例 #1
0
        public void SendMessage(TransactionMessage message)
        {
            // Ensure that we aren't going to run over memory
            if (message.DataBuffer.Length < message.DataOffset + message.DataLength)
            {
                throw new ArgumentException("DataOffset + DataLength > Message Buffer size");
            }
            if (message.DataOffset < 0 || message.DataLength < 0)
            {
                throw new ArgumentException("Either DataOffset or DataLength was negative");
            }
//         if (message.DataLength + 4 + 4 > DTPConstants.kMaxMessageSize)
//            throw new ArgumentException("Frame (header + payload) was too big (> max size)");

            // Take frame buffer and copy contents to it
            int frameSize   = 4 + 4 + message.DataLength;
            var frameBuffer = TakeFrameBuffer(frameSize);

            fixed(byte *pFrameBuffer = frameBuffer)
            fixed(byte *pMessageBuffer = message.DataBuffer)
            {
                *(uint *)(pFrameBuffer + 0) = (uint)frameSize;
                *(uint *)(pFrameBuffer + 4) = (uint)message.TransactionId;

                byte *pMessageContent     = pMessageBuffer + message.DataOffset;
                byte *pFrameBufferContent = pFrameBuffer + 8;

                memcpy(new IntPtr(pFrameBufferContent), new IntPtr(pMessageContent), message.DataLength);
            }
            m_frameBuffersToSend.Add(frameBuffer);
        }
 /// <summary>
 /// Processes a message recieved from the remote endpoint
 /// </summary>
 /// <param name="session">
 /// DSPEx session object, which permits us to send messages.
 /// </param>
 /// <param name="message">
 /// The recieved DSPEx message which we are to process.
 /// </param>
 public abstract void ProcessMessage(IDSPExSession session, TransactionMessage message);