示例#1
0
 /// <summary>
 /// Convert a message to a packet using end mark.
 /// </summary>
 /// <param name="messageData">The message data to convert.</param>
 /// <param name="offset">The offset of the message data.</param>
 /// <param name="count">The count of bytes to convert.</param>
 /// <returns>The converted packet with end mark if UseMakePacket property is true; otherwise the input message data with doing nothing.</returns>
 public byte[] MakePacket(byte[] messageData, int offset, int count)
 {
     Contract.Requires(messageData != null && messageData.Length > 0);
     if (!UseMakePacket)
     {
         if (offset == 0 && count == messageData.Length)
         {
             return(messageData);
         }
         return(new ArraySegment <byte>(messageData, offset, count).ToArray());
     }
     return(ByteArrayHelper.ByteArrayJoin(messageData, _endMark));
 }