/// <summary>
        /// Creates an account and use new account to login
        /// </summary>
        /// <param name="session">The client that sended the data</param>
        /// <param name="dict">The request that the stream sended</param>
        public static void NewUser(GPCMSession session, Dictionary <string, string> dict)
        {
            //Format the password for our database storage
            GPErrorCode error = IsRequestContainAllKeys(dict);

            //if there do not recieved right <key,value> pairs we send error
            if (error != GPErrorCode.NoError)
            {
                GameSpyUtils.SendGPError(session, 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;

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

            //if the request did not contain uniquenick and namespaceid we use our way to create it.
            PreProcessRequest(dict);
            //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(session, GPErrorCode.DatabaseError, "Account is existed, please use another one.");
            }
            else
            {
                sendingBuffer = string.Format(@"\nur\0\pid\{0}\final\", profileid);
                session.Send(sendingBuffer);
            }
        }
Beispiel #2
0
 /// <summary>
 /// Polls the connection, and checks for drops
 /// </summary>
 public static void SendKeepAlive(GPCMSession session)
 {
     if (session.PlayerInfo.LoginProcess == LoginStatus.Completed)
     {
         // Try and send a Keep-Alive
         try
         {
             session.Send(@"\ka\\final\");
         }
         catch
         {
             session.DisconnectByReason(DisconnectReason.KeepAliveFailed);
         }
     }
 }
        /// <summary>
        /// update the uniquenick
        /// </summary>
        /// <param name="session"></param>
        /// <param name="dict"></param>
        public static void RegisterNick(GPCMSession session, Dictionary <string, string> dict)
        {
            GPErrorCode error = IsContainAllKeys(dict);

            if (error != GPErrorCode.NoError)
            {
                GameSpyUtils.SendGPError(session, error, "Parsing error");
                return;
            }
            string sendingBuffer;

            try
            {
                RegisterNickQuery.UpdateUniquenick(dict["uniquenick"], session.PlayerInfo.SessionKey, Convert.ToUInt16(dict["patnerid"]));
                sendingBuffer = @"\rn\final\";
                session.Send(sendingBuffer);
            }
            catch (Exception e)
            {
                LogWriter.Log.WriteException(e);
            }
        }