示例#1
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.");
            }
        }
        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
        }
        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.");
        }
示例#4
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);
            }
        }
        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\
        }