コード例 #1
0
        public void Login(IEnumerable <string> scope, string callback_id)
        {
            this.LogMethodCall();
            var result = MockResults.GetLoginResult(int.Parse(callback_id), scope.ToCommaSeparateList(), this.ResultExtras);

            this.Facebook.OnLoginComplete(new ResultContainer(result));
        }
コード例 #2
0
        public void ExternalCall(string functionName, object[] args)
        {
            this.LogMethodCall(functionName);
            IDictionary <string, object> result;

            Utilities.Callback <ResultContainer> callback = null;

            if (functionName == "FBUnity.init")
            {
                result   = MockResults.GetGenericResult(0, this.ResultExtras);
                callback = this.Facebook.OnInitComplete;
            }
            else if (functionName == "FBUnity.logAppEvent")
            {
                // Workaround log the method call to match the signature of ios and android.
                this.LogMethodCall("LogAppEvent");

                // No callback on log app event
                return;
            }
            else if (functionName == "FBUnity.login")
            {
                var permissions = (IEnumerable <string>)args[0];
                var callbackID  = int.Parse((string)args[1]);
                result   = MockResults.GetLoginResult(callbackID, permissions, this.ResultExtras);
                callback = this.Facebook.OnLoginComplete;
            }
            else if (functionName == "FBUnity.ui")
            {
                var callbackMetod = (string)args[2];
                var callbackID    = int.Parse((string)args[1]);

                if (callbackMetod == Constants.OnAppRequestsCompleteMethodName)
                {
                    result   = MockResults.GetGenericResult(callbackID, this.ResultExtras);
                    callback = this.Facebook.OnAppRequestsComplete;
                }
                else if (callbackMetod == Constants.OnShareCompleteMethodName)
                {
                    result   = MockResults.GetGenericResult(callbackID, this.ResultExtras);
                    callback = this.Facebook.OnShareLinkComplete;
                }
                else if (callbackMetod == Constants.OnPayCompleteMethodName)
                {
                    result   = MockResults.GetGenericResult(callbackID, this.ResultExtras);
                    callback = this.CanvasFacebook.OnPayComplete;
                }
                else
                {
                    throw new NotImplementedException("Mock missing ui function: " + callbackMetod);
                }
            }
            else
            {
                throw new NotImplementedException("Mock missing function: " + functionName);
            }

            callback(new ResultContainer(result));
        }
コード例 #3
0
        public void ShowLoginMockDialog(
            Utilities.Callback <ResultContainer> callback,
            string callbackId,
            string permissions)
        {
            var result = MockResults.GetLoginResult(int.Parse(callbackId), permissions, this.ResultExtras);

            callback(new ResultContainer(result));
        }
コード例 #4
0
        public void RefreshCurrentAccessToken(int requestID)
        {
            var result = MockResults.GetLoginResult(
                requestID,
                string.Empty,
                this.ResultExtras);

            this.MobileFacebook.OnRefreshCurrentAccessTokenComplete(new ResultContainer(result));
        }
コード例 #5
0
        public void DoLoginRequest(
            string appID,
            string permissions,
            string callbackID,
            GameroomFacebook.OnComplete completeDelegate)
        {
            var result = MockResults.GetLoginResult(int.Parse(callbackID), permissions, this.ResultExtras);

            completeDelegate(new ResultContainer(result));
        }
コード例 #6
0
        private void LoginCommon(
            int requestID,
            string scope)
        {
            var result = MockResults.GetLoginResult(
                requestID,
                scope,
                this.ResultExtras);

            this.Facebook.OnLoginComplete(new ResultContainer(result));
        }
コード例 #7
0
        public void CallStatic(string methodName, params object[] args)
        {
            this.LogMethodCall(methodName);
            Utilities.Callback <ResultContainer> callback = null;
            IDictionary <string, object>         result;
            IDictionary <string, object>         methodArguments = null;
            int callbackID = -1;

            if (args.Length == 1)
            {
                var jsonParams = (string)args[0];
                if (jsonParams != null)
                {
                    methodArguments = MiniJSON.Json.Deserialize(jsonParams) as IDictionary <string, object>;
                    string callbackStr;
                    if (methodArguments != null && methodArguments.TryGetValue(Constants.CallbackIdKey, out callbackStr))
                    {
                        callbackID = int.Parse(callbackStr);
                    }
                }
            }

            if (callbackID == -1 && methodName != "Init")
            {
                // There was no callback so just return;
                return;
            }

            if (methodName == "Init")
            {
                callback = this.MobileFacebook.OnInitComplete;
                result   = MockResults.GetGenericResult(0, this.ResultExtras);
            }
            else if (methodName == "GetAppLink")
            {
                callback = this.Facebook.OnGetAppLinkComplete;
                result   = MockResults.GetGenericResult(callbackID, this.ResultExtras);
            }
            else if (methodName == "AppRequest")
            {
                callback = this.Facebook.OnAppRequestsComplete;
                result   = MockResults.GetGenericResult(callbackID, this.ResultExtras);
            }
            else if (methodName == "FeedShare")
            {
                callback = this.Facebook.OnShareLinkComplete;
                result   = MockResults.GetGenericResult(callbackID, this.ResultExtras);
            }
            else if (methodName == "ShareLink")
            {
                callback = this.Facebook.OnShareLinkComplete;
                result   = MockResults.GetGenericResult(callbackID, this.ResultExtras);
            }
            else if (methodName == "LoginWithPublishPermissions" || methodName == "LoginWithReadPermissions")
            {
                callback = this.Facebook.OnLoginComplete;
                string permissions;
                methodArguments.TryGetValue(AndroidFacebook.LoginPermissionsKey, out permissions);
                result = MockResults.GetLoginResult(
                    callbackID,
                    permissions,
                    this.ResultExtras);
            }
            else if (methodName == "RefreshCurrentAccessToken")
            {
                callback = this.MobileFacebook.OnRefreshCurrentAccessTokenComplete;
                result   = MockResults.GetLoginResult(
                    callbackID,
                    string.Empty,
                    this.ResultExtras);
            }
            else
            {
                throw new NotImplementedException("Not implemented for " + methodName);
            }

            callback(new ResultContainer(result));
        }