Ejemplo n.º 1
0
        /// <summary>
        /// Tell server send back extra information according to the number of  sdkrevision
        /// </summary>
        public static void Switch(GPCMSession session, Dictionary <string, string> recv)
        {
            switch (Convert.ToInt32(session.PlayerInfo.SDKRevision))
            {
            case Type1:
                SendBuddiesHandler.SendBuddyList(session);
                SendBlockListHandler.SendBlockList(session);
                break;

            case Type2:
                SendBuddiesHandler.SendBuddyList(session);
                SendBlockListHandler.SendBlockList(session);
                break;

            case Type3:
                SendBuddiesHandler.SendBuddyList(session);
                break;

            case Type4:
                SendBuddiesHandler.SendBuddyList(session);
                break;

            default:
                session.ToLog("No sdkrevision found");
                break;
            }
        }
Ejemplo n.º 2
0
        private void ParseDataBasedOnLoginType(GPCMSession session)
        {
            session.PlayerInfo.UserChallenge = _recv["challenge"];

            if (_recv.ContainsKey("uniquenick"))
            {
                session.PlayerInfo.LoginType  = LoginType.Uniquenick;
                session.PlayerInfo.UniqueNick = _recv["uniquenick"];
                session.PlayerInfo.UserData   = _recv["uniquenick"];
                return;
            }
            if (_recv.ContainsKey("authtoken"))
            {
                session.PlayerInfo.LoginType = LoginType.AuthToken;
                session.PlayerInfo.AuthToken = _recv["authtoken"];
                session.PlayerInfo.UserData  = _recv["authtoken"];
                return;
            }
            if (_recv.ContainsKey("user"))
            {
                session.PlayerInfo.LoginType = LoginType.Nick;
                session.PlayerInfo.UserData  = _recv["user"];
                string user = _recv["user"];

                int Pos = user.IndexOf('@');
                if (Pos == -1 || Pos < 1 || (Pos + 1) >= user.Length)
                {
                    // Ignore malformed user
                    // Pos == -1 : Not found
                    // Pos < 1 : @ or @example
                    // Pos + 1 >= Length : example@
                    _errorCode = GPErrorCode.LoginBadEmail;
                    return;
                }
                string nick  = user.Substring(0, Pos);
                string email = user.Substring(Pos + 1);

                session.PlayerInfo.Nick      = nick;
                session.PlayerInfo.Email     = email;
                session.PlayerInfo.LoginType = LoginType.Nick;
                return;
            }

            //if no login method found we can not continue.
            session.ToLog("Unknown login method detected!");
            _errorCode = GPErrorCode.Parse;
        }