Esempio n. 1
0
        /// <summary>
        ///     Gets the reversed bytes.
        /// </summary>
        /// <returns>System.Byte[].</returns>
        public byte[] GetReversedBytes()
        {
            byte[] bytes;

            using (MemoryStream finalBuffer = new MemoryStream())
            {
                byte[] length = BitConverter.GetBytes((int)CurrentMessage.Length);
                Array.Reverse(length);
                finalBuffer.Write(length, 0, length.Length);

                CurrentMessage.WriteTo(finalBuffer);

                bytes = finalBuffer.ToArray();
            }

            if (Yupi.PacketDebugMode)
            {
                Console.ForegroundColor = ConsoleColor.DarkBlue;
                Console.WriteLine();
                Console.Write("OUTGOING ");
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.Write("PREPARED ");
                Console.ForegroundColor = ConsoleColor.DarkGray;
                Console.Write(Id + Environment.NewLine +
                              HabboEncoding.GetCharFilter(Yupi.GetDefaultEncoding().GetString(bytes)));
                Console.WriteLine();
            }

            return(bytes);
        }
Esempio n. 2
0
        /// <summary>
        ///     Appends the string.
        /// </summary>
        /// <param name="s">The s.</param>
        /// <param name="isUtf8">If string is UTF8</param>
        public void AppendString(string s, bool isUtf8 = false)
        {
            Encoding encoding = isUtf8 ? Encoding.UTF8 : Yupi.GetDefaultEncoding();

            byte[] bytes = encoding.GetBytes(s);
            AppendShort(bytes.Length);
            AppendBytes(bytes, false);
        }
Esempio n. 3
0
 internal static void Set()
 {
     XmlPolicyBytes =
         Yupi.GetDefaultEncoding()
         .GetBytes(
             "<?xml version=\"1.0\"?>\r\n<!DOCTYPE cross-domain-policy SYSTEM \"/xml/dtds/cross-domain-policy.dtd\">\r\n<cross-domain-policy>\r\n<allow-access-from domain=\"*\" to-ports=\"" +
             ServerConfigurationSettings.Data["game.tcp.port.proxy"] + "\" />\r\n</cross-domain-policy>\0");
 }
Esempio n. 4
0
 /// <summary>
 ///     Returns a <see cref="System.String" /> that represents this instance.
 /// </summary>
 /// <returns>A <see cref="System.String" /> that represents this instance.</returns>
 public override string ToString()
 => HabboEncoding.GetCharFilter(Yupi.GetDefaultEncoding().GetString(GetReversedBytes()));