Esempio n. 1
0
        /// <summary>
        /// Converts an IoP Profile Server Network protocol message to a binary format.
        /// </summary>
        /// <param name="Data">IoP Profile Server Network protocol message.</param>
        /// <returns>Binary representation of the message to be sent over the network.</returns>
        public static byte[] MessageToByteArray(IProtocolMessage Data)
        {
            MessageWithHeader mwh = new MessageWithHeader();

            mwh.Body = (Message)Data.Message;
            // We have to initialize the header before calling CalculateSize.
            mwh.Header = 1;
            mwh.Header = (uint)mwh.CalculateSize() - ProtocolHelper.HeaderSize;
            return(mwh.ToByteArray());
        }
Esempio n. 2
0
        /// <summary>
        /// Converts an IoP Home Network protocol message to a binary format.
        /// </summary>
        /// <param name="Data">Home Network protocol message.</param>
        /// <returns>Binary representation of the message to be sent over the network.</returns>
        public static byte[] GetMessageBytes(Message Data)
        {
            MessageWithHeader mwh = new MessageWithHeader();

            mwh.Body = Data;
            // We have to initialize the header before calling CalculateSize.
            mwh.Header = 1;
            mwh.Header = (uint)mwh.CalculateSize() - HeaderSize;
            return(mwh.ToByteArray());
        }