public static void SearchOtherBuddyList(GPSPClient client, Dictionary <string, string> dict)
        {
            //request: \otherslist\sesskey\<searcher's sesskey>\profileid\<searcher's pid>\numopids\<how many pid in his list>
            //\opids\|<opid1>|<opid2>|******\namespaceid\<>\gamename\<>\final\

            string[] opids = dict["opids"].TrimStart('|').Split('|');
            // response: @"\otherslist\o\<o>\uniquenick\<uniquenick>\oldone\final\";
            string sendingBuffer = @"\otherslist\";

            foreach (string pid in opids)
            {
                List <Dictionary <string, object> > temp = OthersListQuery.GetOtherBuddyList(dict, pid);
                if (temp == null)
                {
                    continue;
                }
                else
                {
                    sendingBuffer += string.Format(@"o\{0}\uniquenick\{1}\", temp[0]["profileid"], temp[0]["uniquenick"]);
                }
            }

            sendingBuffer += @"oldone\final\";

            client.Send(sendingBuffer);



            //GameSpyUtils.PrintReceivedGPDictToLogger("otherslist", dict);
            //GameSpyUtils.SendGPError(client.Stream, GPErrorCode.General, "This request is not supported yet.");
        }
예제 #2
0
        public static void PlayerMatch(GPSPClient client, Dictionary <string, string> dict)
        { //pmath\\sesskey\\profileid\\productid\\
            string sendingBuffer;

            if (IsContainAllKey(dict))
            {
                List <Dictionary <string, object> > temp = PmatchQuery.PlayerMatch(dict);
                if (temp.Count == 1)
                {
                    sendingBuffer = string.Format(@"\psr\status\{0}\nick\{1}\statuscode\{2}\final\",
                                                  temp[0]["status"], temp[0]["nick"], temp[0]["statuscode"]);
                    client.Send(sendingBuffer);
                }
                else
                {
                    GameSpyUtils.SendGPError(client, GPErrorCode.DatabaseError, "No match found!");
                }
            }

            //there are two ways to send information back.

            //First way: \psr\<profileid>\status\<status>\statuscode\<statuscode>\psrdone\final\

            //this is a multiple command. you can contain mutiple \psr\........... in the Steam
            //Second way:\psr\<profileid>\nick\<nick>\***multiple \psr\ command***\psrdone\final\
            //<status> is like the introduction in a player homepage
            //<statuscode> mean the status information is support or not the value should be as follows
            //GP_NEW_STATUS_INFO_SUPPORTED = 0xC00,
            //GP_NEW_STATUS_INFO_NOT_SUPPORTED = 0xC01
        }
예제 #3
0
        /// <summary>
        /// check if a email is exist in database
        /// </summary>
        /// <param name="client"></param>
        /// <param name="dict"></param>
        public static void IsEmailValid(GPSPClient client, Dictionary <string, string> dict)
        {
            if (!dict.ContainsKey("email"))
            {
                GameSpyUtils.SendGPError(client, GPErrorCode.Parse, "There was an error parsing an incoming request.");
                return;
            }

            try
            {
                if (GameSpyUtils.IsEmailFormatCorrect(dict["email"]))
                {
                    if (ValidQuery.IsEmailValid(dict))
                    {
                        client.Send(@"\vr\1\final\");
                    }
                    else
                    {
                        client.Send(@"\vr\0\final\");
                    }

                    //client.Stream.Dispose();
                }
                else
                {
                    client.Send(@"\vr\0\final\");
                    //client.Stream.Dispose();
                }
            }
            catch (Exception ex)
            {
                LogWriter.Log.WriteException(ex);
                GameSpyUtils.SendGPError(client, GPErrorCode.DatabaseError, "This request cannot be processed because of a database error.");
            }
        }
예제 #4
0
        /// <summary>
        /// Get profiles that have you on their buddy(friend) list.
        /// </summary>
        /// <param name="client"></param>
        /// <param name="dict"></param>
        public static void SearchOtherBuddy(GPSPClient client, Dictionary <string, string> dict)
        {
            // TODO: Please finis this function
            //others\sesskey\profileid\namespace\
            string sendingbuffer; //= @"\others\o\nick\<>\uniquenick\<>\first\<>\last\<>\email\<>\odone\";
            var    temp = OthersQuery.GetOtherBuddy(dict);

            if (temp == null)
            {
                GameSpyUtils.SendGPError(client, GPErrorCode.DatabaseError, "No Math Found");
                return;
            }
            if (temp.Count == 1)
            {
                sendingbuffer = string.Format(@"\others\o\nick\{0}\uniquenick\{1}\first\{2}\last\{3}\email\{4}\odone\final\", temp[0]["nick"], temp[0]["uniquenick"], temp[0]["firstname"], temp[0]["lastname"], temp[0]["email"]);
                client.Stream.SendAsync(sendingbuffer);
                return;
            }
            if (temp.Count > 1)
            {
                sendingbuffer = @"\others\";
                foreach (Dictionary <string, object> info in temp)
                {
                    sendingbuffer += string.Format(@"o\nick\{0}\uniquenick\{1}\first\{1}\last\{2}\email\{3}\", info["nick"], info["uniquenick"], info["firstname"], info["lastname"], info["email"]);
                }
                client.Stream.SendAsync(sendingbuffer);
                return;
            }

            GameSpyUtils.PrintReceivedGPDictToLogger("others", dict);
            GameSpyUtils.SendGPError(client, GPErrorCode.General, "This request is not supported yet.");
        }
예제 #5
0
        /// <summary>
        /// Get nickname through email and password
        /// </summary>
        /// <param name="client"></param>
        /// <param name="dict"></param>
        public static void SearchNicks(GPSPClient client, Dictionary <string, string> dict)
        {
            //Format the password for our database storage
            //if not recieved correct request we terminate
            GPErrorCode error = IsSearchNicksContianAllKeys(dict);

            if (error != GPErrorCode.NoError)
            {
                GameSpyUtils.SendGPError(client, (int)error, "Error recieving SearchNicks request.");
                return;
            }

            List <Dictionary <string, object> > queryResult;

            try
            {
                //get nicknames from GPSPDBQuery class
                queryResult = NickQuery.RetriveNicknames(dict);
            }
            catch (Exception ex)
            {
                LogWriter.Log.Write(ex.Message, LogLevel.Error);
                GameSpyUtils.SendGPError(client, GPErrorCode.DatabaseError, "This request cannot be processed because of a database error.");
                return;
            }

            if (queryResult.Count < 1)
            {
                GameSpyUtils.SendGPError(client, GPErrorCode.DatabaseError, "No match found !");
                return;
            }

            string sendingBuffer;

            sendingBuffer = @"\nr\";
            foreach (Dictionary <string, object> row in queryResult)
            {
                sendingBuffer += @"\nick\";
                sendingBuffer += row["nick"];
                sendingBuffer += @"\uniquenick\";
                sendingBuffer += row["uniquenick"];
            }

            sendingBuffer += @"\ndone\final\";
            client.Stream.SendAsync(sendingBuffer);
        }
예제 #6
0
        /// <summary>
        /// Creates an account and use new account to login
        /// </summary>
        /// <param name="client">The client that sended the data</param>
        /// <param name="dict">The request that the stream sended</param>
        public static void NewUser(GPSPClient client, Dictionary <string, string> dict)
        {
            //Format the password for our database storage
            GPErrorCode error = IsContainAllKeys(dict);

            //if there do not recieved right <key,value> pairs we send error
            if (error != GPErrorCode.NoError)
            {
                GameSpyUtils.SendGPError(client, error, "Error recieving request. Please check the input!");
                return;
            }
            //Check the nick and uniquenick is formated correct and uniquenick is existed in database
            string sendingBuffer;

            PreProcessRequest(dict);
            error = IsEmailNickUniquenickValied(dict);
            if (error != GPErrorCode.NoError)
            {
                sendingBuffer = string.Format(@"\nur\{0}\final\", (int)error);
                client.Stream.SendAsync(sendingBuffer);
                return;
            }

            //if the request did not contain uniquenick and namespaceid we use our way to create it.

            //we get the userid in database. If no userid found according to email we create one
            //and store the new account into database.
            int profileid = CreateAccount(dict);

            if (profileid == -1)
            {
                GameSpyUtils.SendGPError(client, GPErrorCode.DatabaseError, "Account is existed, please use another one.");
            }
            else
            {
                client.Stream.SendAsync(@"\nur\0\pid\{0}\final\", profileid);
            }
        }
예제 #7
0
        /// <summary>
        /// we just simply check the existance of the unique nickname in the database and suggest some numbered postfix nickname
        /// </summary>
        /// <param name="client"></param>
        /// <param name="dict"></param>
        public static void SuggestUniqueNickname(GPSPClient client, Dictionary <string, string> dict)
        {
            //The multiple nick suggest correct response is like
            //@"\us\<number of suggested nick>\nick\<nick1>\nick\<nick2>\usdone\final\";
            string      sendingBuffer;
            GPErrorCode error = IsContainAllKeys(dict);

            if (error != GPErrorCode.NoError)
            {
                GameSpyUtils.SendGPError(client, GPErrorCode.Parse, "There was an error parsing an incoming request.");
                return;
            }

            if (UniqueSearchQuery.IsUniqueNickExist(dict))
            {
                GameSpyUtils.SendGPError(client, GPErrorCode.General, "The Nick is existed, please choose another name");
            }
            else
            {
                sendingBuffer = @"\us\1\nick\" + dict["preferrednick"] + @"\usdone\final\";
                client.Send(sendingBuffer);
            }
        }
예제 #8
0
        /// <summary>
        /// Validates a user's info, without logging into the account.
        /// </summary>
        /// <param name="client"></param>
        /// <param name="dict"></param>
        public static void CheckProfileid(GPSPClient client, Dictionary <string, string> dict)
        {
            // \check\\nick\<nick>\email\<email>\partnerid\0\passenc\<passenc>\gamename\gmtest\final\
            //\cur\pid\<pid>\final
            //check is request recieved correct and convert password into our MD5 type
            bool isContiansAllKey = dict.ContainsKey("nick") && dict.ContainsKey("email") && (dict.ContainsKey("passenc") || dict.ContainsKey("pass"));

            if (!isContiansAllKey)
            {
                GameSpyUtils.SendGPError(client, GPErrorCode.Parse, "Parsing error, please check input.");
                return;
            }
            bool isEmailCorrect = GameSpyUtils.IsEmailFormatCorrect(dict["email"]);

            if (!isEmailCorrect)
            {
                GameSpyUtils.SendGPError(client, GPErrorCode.Parse, "Email format not correct.");
                return;
            }


            //Search pid in our database and return whether exist
            string sendingBuffer;
            int    profileid = CheckQuery.GetProfileidFromNickEmailPassword(dict);

            if (profileid != -1)
            {
                sendingBuffer = string.Format(@"\cur\0\pid\{0}\final\", profileid);
                client.Stream.SendAsync(sendingBuffer);
            }
            else
            {
                sendingBuffer = "No math found";
                GameSpyUtils.SendGPError(client, GPErrorCode.DatabaseError, sendingBuffer);
            }
        }
예제 #9
0
        public static void SearchUsers(GPSPClient client, Dictionary <string, string> dict)
        {
            //string sendingbuffer = "\\bsr\\1\\nick\\mycrysis\\uniquenick\\1\\namespaceid\\0\\firstname\\jiangheng\\lastname\\kou\\email\\[email protected]\\bsrdone\\0\\final\\";
            //client.Stream.SendAsync(sendingbuffer);

            string      sendingBuffer;
            GPErrorCode error;

            error = IsLogIn(dict);
            //if (error != GPErrorCode.NoError)
            //{
            //    GameSpyUtils.SendGPError(client.Stream, error, "You must login to use search functions");
            //    return;
            //}

            //we only need uniquenick to search a profile
            if (dict.ContainsKey("uniquenick"))
            {
                error = SearchWithUniquenick(dict, out sendingBuffer);
                if (error != GPErrorCode.NoError)
                {
                    GameSpyUtils.SendGPError(client, error, sendingBuffer);
                }
                else
                {
                    client.Send(sendingBuffer);
                }
                return;
            }

            if (dict.ContainsKey("nick") && dict.ContainsKey("email"))
            {
                //exist nick and email which can identify multiple profiles
                //you have to add \more\bsr\******\final\
                error = SearchWithNickEmail(dict, out sendingBuffer);
                if (error != GPErrorCode.NoError)
                {
                    GameSpyUtils.SendGPError(client, error, sendingBuffer);
                }
                else
                {
                    client.Send(sendingBuffer);
                }
                return;
            }

            if (dict.ContainsKey("email"))
            {
                error = SearchWithEmail(dict, out sendingBuffer);
                if (error != GPErrorCode.NoError)
                {
                    GameSpyUtils.SendGPError(client, error, sendingBuffer);
                }
                else
                {
                    client.Send(sendingBuffer);
                }
                return;
            }
            //if above 3 functions not excuted then it must be parsing error
            GameSpyUtils.SendGPError(client, GPErrorCode.Parse, "There is a parse error in request!");

            //last one we search with email this may get few profile so we can not return GPErrorCode
            //SearchWithEmail(client,dict );
            //client.Stream.SendAsync(@"\bsr\1\nick\1\uniquenick\1\namespaceid\1\firstname\1\lastname\1\email\1\bsrdone\\more\bsr\2\nick\2\uniquenick\2\namespaceid\2\firstname\2\lastname\2\email\2\bsrdone\\final\");
            //we need full information to find a player.
            //if recieved data contians nick, uniquenick, email,
            //a player must need to login to use the search function. sessionkey is 0 or else and profileid also.
            //case1:  uniquenick  email . check uniquenick email is exist or not
            //case4:  uniquenick
            //case2:  nick uniquenick email
            //case3:  nick uniquenick
            //case5:  nick   email gamename
            //case6:  nick
            //if not contain email, we need to
            //\search\\sesskey\0\profileid\0\namespaceid\1\partnerid\0\nick\mycrysis\uniquenick\xiaojiuwo\email\[email protected]\gamename\gmtest\final\
            //\bsrdone\more\<more>\final\
            //\bsr\
        }
 public static void SearchProfileWithUniquenick(GPSPClient client, Dictionary <string, string> dict)
 {
     GameSpyUtils.PrintReceivedGPDictToLogger("searchunique", dict);
     GameSpyUtils.SendGPError(client, GPErrorCode.General, "This request is not supported yet.");
 }