Esempio n. 1
0
        /// <summary>
        /// This method is requested by the client when logging in to fetch all the account
        /// names that have the specified email address and password combination
        /// </summary>
        /// <param name="recvData"></param>
        private void SendNicks(Dictionary <string, string> recvData)
        {
            // Make sure we have the needed data
            if (!recvData.ContainsKey("email") || (!recvData.ContainsKey("pass") && !recvData.ContainsKey("passenc")))
            {
                Stream.SendAsync(@"\error\\err\0\fatal\\errmsg\Invalid Query!\id\1\final\");
                return;
            }

            // Try to get user data from database
            try
            {
                // Get our password from the provided query
                string password = (recvData.ContainsKey("pass"))
                    ? recvData["pass"]
                    : GamespyUtils.DecodePassword(recvData["passenc"]);

                // Fetch soldiers that match this email and password
                using (GamespyDatabase Db = new GamespyDatabase())
                {
                    var           Clients  = Db.GetUsersByEmailPass(recvData["email"], password);
                    StringBuilder Response = new StringBuilder(@"\nr\" + Clients.Count);
                    for (int i = 0; i < Clients.Count; i++)
                    {
                        Response.AppendFormat(@"\nick\{0}\uniquenick\{0}", Clients[i]["name"]);
                    }

                    Response.Append(@"\ndone\\final\");
                    Stream.SendAsync(Response.ToString());
                }
            }
            catch
            {
                Stream.SendAsync(@"\error\\err\551\fatal\\errmsg\Unable to get any associated profiles.\id\1\final\");
            }
        }