Inheritance: IDisposable
Esempio n. 1
0
    Carrot()
    {
        mCarrotCache = new CarrotCache();
        this.InstallDate = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(mCarrotCache.InstallDate);

        // Check to see if the official Facebook SDK is being used
        mFacebookDelegateType = Type.GetType("Facebook.FacebookDelegate,IFacebook");
        if(mFacebookDelegateType != null)
        {
            Type t = Type.GetType("FB");
            mOfficialFBSDKFeedMethod = t.GetMethod("Feed", BindingFlags.Static | BindingFlags.Public);

            t = Type.GetType("FBResult,IFacebook");
            mFBResultPropertyText = t.GetProperty("Text");
            mFBResultPropertyError = t.GetProperty("Error");
            mFacebookDelegateType = Type.GetType("Facebook.FacebookDelegate,IFacebook");

            if(mFacebookDelegateType != null &&
               mOfficialFBSDKFeedMethod != null &&
               mFBResultPropertyText != null &&
               mFBResultPropertyError != null &&
               mFacebookDelegateType != null)
            {
                mFacebookSDKType = FacebookSDKType.OfficialUnitySDK;
            }
        }
        #if UNITY_WEBPLAYER
        // If on Unity WebPlayer, some use the JavaScript SDK
        else
        {
            Application.ExternalEval("if(window.__carrotUnityInstance == null || window.__carrotUnityInstance == undefined) {" +
                                     "    window.__carrotUnityInstance = UnityObject2.instances[0];" +
                                     "}" +
                                     "window.__carrotUnityInstance.getUnity().SendMessage('CarrotGameObject', 'assignUnityObject2Instance', 'window.__carrotUnityInstance');"
            );
        }
        #endif
    }
Esempio n. 2
0
    private CarrotRequestResponse cachedRequestHandler(CarrotCache.CachedRequest cachedRequest,
                                                       CarrotRequestResponse callback)
    {
        return (Response ret, string errorText, Dictionary<string, object> reply) => {
                switch(ret)
                {
                    case Response.OK:
                    case Response.NotFound:
                    case Response.ParameterError:
                        cachedRequest.RemoveFromCache();
                        break;

                    default:
                        cachedRequest.AddRetryInCache();
                        break;
                }
                if(callback != null) callback(ret, errorText, reply);
        };
    }