コード例 #1
0
ファイル: Pandora.cs プロジェクト: rioniac/Elpis
        protected internal JSONResult CallRPC(string method, JObject request = null,
                                              bool isAuth = false, bool useSSL = false)
        {
            string     response = CallRPC_Internal(method, request, isAuth, useSSL);
            JSONResult result   = new JSONResult(response);

            if (result.Fault)
            {
                if (!HandleFaults(result, false))
                {
                    Log.O("Reauth Required");
                    if (!AuthenticateUser())
                    {
                        HandleFaults(result, true);
                    }
                    else
                    {
                        response = CallRPC_Internal(method, request, isAuth, useSSL);
                        HandleFaults(result, true);
                    }
                }
            }

            return(result);
        }
コード例 #2
0
ファイル: Pandora.cs プロジェクト: wade1990/Elpis
        //Checks for fault returns.  If it's an Auth fault (auth timed out)
        //return false, which signals that a re-auth and retry needs to be done
        //otherwise return true signalling all clear.
        //All other faults will be thrown
        protected internal bool HandleFaults(JSONResult result, bool secondTry)
        {
            if (result.Fault)
            {
                if (result.FaultCode == ErrorCodes.INVALID_AUTH_TOKEN)
                {
                    if (!secondTry)
                    {
                        return(false); //auth fault, signal a re-auth
                    }
                }
                Log.O("Fault: " + result.FaultString);
                throw new PandoraException(result.FaultCode); //other, throw the exception
            }

            return(true); //no fault
        }