Exemplo n.º 1
0
 static WearableProxyProtocolBase()
 {
     _footer = new PacketFooter {
         terminator = Terminator
     };
     _headerSize     = Marshal.SizeOf(typeof(PacketHeader));
     _footerSize     = Marshal.SizeOf(typeof(PacketFooter));
     _stringEncoding = Encoding.ASCII;
 }
        /// <summary>
        /// Checks that the buffer provided has a valid footer at the current index.
        /// </summary>
        /// <param name="buffer"></param>
        /// <param name="index"></param>
        /// <exception cref="WearableProxyProtocolException">Thrown if the footer was invalid.</exception>
        protected static void CheckFooter(byte[] buffer, ref int index)
        {
            PacketFooter footer = DeserializePacket <PacketFooter>(buffer, ref index);

            if (footer.terminator != Terminator)
            {
                // This is a corrupt or de-synchronized packet
                throw new WearableProxyProtocolException(WearableConstants.ProxyProviderInvalidPacketError);
            }
        }