Beispiel #1
0
        /// <summary>
        /// Removes random padding from a message array
        /// </summary>
        /// 
        /// <param name="Data">The message aray</param>
        /// 
        /// <returns>The unwrapped message</returns>
        private byte[] UnwrapMessage(byte[] Data)
        {
            DtmMessage msg = new DtmMessage(Data);
            int hdrLen = msg.GetHeaderSize();

            // remove prepended padding
            if (msg.MessagePrePend > 0)
                ArrayUtils.RemoveRange(ref Data, 0, (msg.MessagePrePend + hdrLen) - 1);
            else
                ArrayUtils.RemoveRange(ref Data, 0, hdrLen - 1);

            // remove appended padding
            if (msg.MessageAppend > 0)
            {
                int pos = Data.Length - msg.MessageAppend;
                ArrayUtils.RemoveRange(ref Data, pos, Data.Length - 1);
            }

            return Data;
        }
Beispiel #2
0
 /// <summary>
 /// Serialize an DtmMessage structure
 /// </summary>
 /// 
 /// <param name="Message">A DtmMessage structure</param>
 /// 
 /// <returns>A stream containing the DtmMessage data</returns>
 public static Stream Serialize(DtmMessage Message)
 {
     return Message.ToStream();
 }