Beispiel #1
0
        public static ErrorCode MobileLogin(string loginID, string password, string clientIP, out long nexonSN, out string nexonID, out ushort age, out bool newMembership, out byte mainAuthLevel, out byte subAuthLevel, out string errorMessage)
        {
            nexonSN       = 0L;
            nexonID       = string.Empty;
            age           = 0;
            newMembership = false;
            mainAuthLevel = 0;
            subAuthLevel  = 0;
            if (loginID == null || password == null)
            {
                errorMessage = "'id' or 'pwd' are null.";
                return(ErrorCode.InvalidArgument);
            }
            if (clientIP == null)
            {
                try
                {
                    clientIP = HttpContext.Current.Request.UserHostAddress;
                }
                catch (Exception)
                {
                    errorMessage = "Getting user ip address from HttpContext failed.";
                    return(ErrorCode.InvalidArgument);
                }
            }
            Default @default;

            try
            {
                @default = Authenticator.CreateClientFromID(loginID);
            }
            catch (Exception ex)
            {
                errorMessage = "A unknown exception occured while creating a soap client." + Environment.NewLine + ex.ToString();
                ErrorLogger.WriteLog(ErrorCode.Unknown, errorMessage, ex.StackTrace, loginID, string.Empty);
                return(ErrorCode.Unknown);
            }
            for (int i = 0; i <= Config.Authenticator.Soap.RetryCount; i++)
            {
                try
                {
                    MobileLoginResult mobileLoginResult = @default.MobileLogin(loginID, password, clientIP);
                    nexonSN       = mobileLoginResult.nNexonSN;
                    nexonID       = mobileLoginResult.strNexonID;
                    age           = mobileLoginResult.uAge;
                    newMembership = mobileLoginResult.bNewMembership;
                    mainAuthLevel = mobileLoginResult.nMainAuthLevel;
                    subAuthLevel  = mobileLoginResult.nSubAuthLevel;
                    errorMessage  = mobileLoginResult.strErrorMessage;
                    return((ErrorCode)mobileLoginResult.nErrorCode);
                }
                catch (Exception ex2)
                {
                    if (i == Config.Authenticator.Soap.RetryCount || !(ex2 is WebException))
                    {
                        errorMessage = "A unknown exception occured while calling a soap method." + Environment.NewLine + ex2.ToString();
                        ErrorLogger.WriteLog(ErrorCode.SoapCallFailed, errorMessage, ex2.StackTrace, loginID, string.Empty);
                        return(ErrorCode.SoapCallFailed);
                    }
                }
                if (i == Config.Authenticator.Soap.RetryCount - 1)
                {
                    @default.Timeout = Config.Authenticator.Soap.LongTimeout;
                }
            }
            errorMessage = string.Empty;
            return(ErrorCode.Unknown);
        }
Beispiel #2
0
        public static ErrorCode Login(string id, string pwd, string ip, int gameCode, int locale, int region, out string passport, out uint unreadNoteCount, out uint statusFlag, out string errorMessage, out int subErrCode)
        {
            passport        = string.Empty;
            unreadNoteCount = 0u;
            statusFlag      = 0u;
            subErrCode      = 0;
            if (id == null || pwd == null)
            {
                errorMessage = "'id' or 'pwd' are null.";
                return(ErrorCode.InvalidArgument);
            }
            if (ip == null)
            {
                try
                {
                    ip = HttpContext.Current.Request.UserHostAddress;
                }
                catch (Exception)
                {
                    errorMessage = "Getting user ip address from HttpContext failed.";
                    return(ErrorCode.InvalidArgument);
                }
            }
            Default @default;

            try
            {
                @default = Authenticator.CreateClientFromID(id);
            }
            catch (Exception ex)
            {
                errorMessage = "A unknown exception occured while creating a soap client." + Environment.NewLine + ex.ToString();
                ErrorLogger.WriteLog(ErrorCode.Unknown, errorMessage, ex.StackTrace, id, passport);
                return(ErrorCode.Unknown);
            }
            int       num = Config.Authenticator.Soap.RetryCount;
            ErrorCode result;

            for (;;)
            {
                try
                {
                    LoginResult2 loginResult = @default.Login4(id, pwd, ip, (uint)gameCode, (uint)locale, (uint)region);
                    if (loginResult.nErrorCode == 0 || loginResult.nErrorCode == 20019)
                    {
                        passport        = loginResult.strPassport;
                        unreadNoteCount = loginResult.uUnreadNoteCount;
                        statusFlag      = loginResult.uStatusFlag;
                    }
                    subErrCode   = loginResult.nSubErrCode;
                    errorMessage = loginResult.strErrorMessage;
                    result       = (ErrorCode)loginResult.nErrorCode;
                    break;
                }
                catch (Exception ex2)
                {
                    if (num == 0 || !(ex2 is WebException))
                    {
                        errorMessage = "A unknown exception occured while calling a soap method." + Environment.NewLine + ex2.ToString();
                        ErrorLogger.WriteLog(ErrorCode.SoapCallFailed, errorMessage, ex2.StackTrace, id, passport);
                        result = ErrorCode.SoapCallFailed;
                        break;
                    }
                }
                num--;
                if (num == 0)
                {
                    @default.Timeout = Config.Authenticator.Soap.LongTimeout;
                }
            }
            return(result);
        }