public void ShowGameGroupCreateMockDialog(
            Utilities.Callback <ResultContainer> callback,
            string callbackId)
        {
            var result = MockResults.GetGroupCreateResult(int.Parse(callbackId), this.ResultExtras);

            callback(new ResultContainer(result));
        }
Ejemplo n.º 2
0
        public void CreateGameGroup(
            int requestId,
            string name,
            string description,
            string privacy)
        {
            this.LogMethodCall();
            var result = MockResults.GetGroupCreateResult(requestId, this.ResultExtras);

            this.Facebook.OnGroupCreateComplete(result.ToJson());
        }
        public void ExternalCall(string functionName, object[] args)
        {
            this.LogMethodCall(functionName);
            IDictionary <string, object> result;
            OnResult callback = null;

            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.OnGroupCreateCompleteMethodName)
                {
                    result   = MockResults.GetGroupCreateResult(callbackID, this.ResultExtras);
                    callback = this.Facebook.OnGroupCreateComplete;
                }
                else if (callbackMetod == Constants.OnGroupJoinCompleteMethodName)
                {
                    result   = MockResults.GetGenericResult(callbackID, this.ResultExtras);
                    callback = this.Facebook.OnGroupJoinComplete;
                }
                else 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(result.ToJson());
        }
Ejemplo n.º 4
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 == "AppInvite")
            {
                callback = this.MobileFacebook.OnAppInviteComplete;
                result   = MockResults.GetGenericResult(callbackID, 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 == "GameGroupCreate")
            {
                callback = this.Facebook.OnGroupCreateComplete;
                result   = MockResults.GetGroupCreateResult(callbackID, this.ResultExtras);
            }
            else if (methodName == "GameGroupJoin")
            {
                callback = this.Facebook.OnGroupJoinComplete;
                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));
        }