Esempio n. 1
0
        /// <summary>
        /// Takes a message sent through the Stream and sends back a respose
        /// </summary>
        /// <param name="message"></param>
        protected void ParseRequest(string message)
        {
            string[] data = message.Split(new char[] { '\x00' }, StringSplitOptions.RemoveEmptyEntries);

            string gamename = data[1].ToLowerInvariant();
            string validate = data[2].Substring(0, 8);
            string filter = data[2].Substring(8);
            string[] fields = data[3].Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries);

            // Fix filter because the filter from BF2 can be messed up, missing spaces and such
            string fixedFilter = FixFilter(filter);
            if (String.IsNullOrEmpty(fixedFilter))
            {
                fixedFilter = "";
            }

            // Send the encrypted serverlist to the client
            byte[] unencryptedServerList = PackServerList(fixedFilter, fields);
            Stream.SendAsync(
                Enctypex.Encode(
                    Encoding.UTF8.GetBytes("hW6m9a"), // Battlfield 2 Handoff Key
                    Encoding.UTF8.GetBytes(validate),
                    unencryptedServerList,
                    unencryptedServerList.LongLength
                )
            );
        }
Esempio n. 2
0
        /// <summary>
        /// Takes a message sent through the Stream and sends back a respose
        /// </summary>
        /// <param name="message"></param>
        public static void ParseRequest(SBSession session, string message)
        {
            string[] data = message.Split(new char[] { '\x00' }, StringSplitOptions.RemoveEmptyEntries);

            string gamename = data[1].ToLowerInvariant();
            string validate = data[2].Substring(0, 8);
            string filter   = FixFilter(data[2].Substring(8));

            string[] fields = data[3].Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries);

            // Send the encrypted serverlist to the client
            byte[] unencryptedServerList = PackServerList(session, filter, fields);
            string sendingBuffer         = Encoding.UTF8.GetString(Enctypex.Encode(
                                                                       Encoding.UTF8.GetBytes("hW6m9a"), // Battlfield 2 Handoff Key
                                                                       Encoding.UTF8.GetBytes(validate),
                                                                       unencryptedServerList,
                                                                       unencryptedServerList.LongLength)
                                                                   );

            session.SendAsync(sendingBuffer);
        }