Пример #1
0
 /**
  * Fetch has two stages:
  * 1. Retrieve the appstore product ids from roar.
  * 2. Use the product ids to retrieve the product details from the appstore.
  **/
 public void Fetch(Roar.Callback <WebObjects.Appstore.ShopListResponse> callback)
 {
     if (isServerCalling)
     {
         return;
     }
     isServerCalling = false;
     productsMap.Clear();
     productsList.Clear();
     actions.shop_list(new Roar.WebObjects.Appstore.ShopListArguments(), new AppstoreListCallback(callback, this));
 }
Пример #2
0
        public void Purchase(string productId, int quantity, Roar.Callback <string> cb, Roar.Callback <Roar.WebObjects.Appstore.BuyResponse> cbx)
        {
            purchaseCallback  = cb;
            purchaseCallbackX = cbx;

                #if UNITY_IOS && !UNITY_EDITOR
            _StoreKitPurchaseQuantity(productId, quantity);
                #else
            logger.DebugLog(string.Format("Can't call _StoreKitPurchase({0}) from Unity Editor", productId));
                #endif
        }
Пример #3
0
        public void DoLoginFacebookSignedReq(string signedReq, Roar.Callback <WebObjects.Facebook.LoginSignedResponse> cb)
        {
            if (signedReq == "")
            {
                logger.DebugLog("[roar] -- Must specify signedReq for facebook login");
                return;
            }

            Roar.WebObjects.Facebook.LoginSignedArguments args = new Roar.WebObjects.Facebook.LoginSignedArguments();
            args.signed_request = signedReq;
            facebook.login_signed(args, new LoginSignedCallback(cb, this));
        }
Пример #4
0
        public void DeclineFriendInvite(string invite_id, Roar.Callback <WebObjects.Friends.DeclineResponse> cb)
        {
            if (invite_id == "")
            {
                logger.DebugLog("[roar] -- Must specify invite_id for declining a friend invite.");
                return;
            }

            WebObjects.Friends.DeclineArguments args = new WebObjects.Friends.DeclineArguments();
            args.invite_id = invite_id;
            friendsActions.decline(args, new DeclineFriendsCallback(cb));
        }
Пример #5
0
        // ---- Original Methods ----
        // ------------------------

        public void LoginOAuth(string oauth_token, Roar.Callback <WebObjects.Facebook.LoginOauthResponse> cb)
        {
            if (oauth_token == "")
            {
                logger.DebugLog("[roar] -- Must specify oauth_token for facebook login");
                return;
            }

            Roar.WebObjects.Facebook.LoginOauthArguments args = new Roar.WebObjects.Facebook.LoginOauthArguments();
            args.oauth_token = oauth_token;
            facebook.login_oauth(args, new LoginOAuthCallback(cb, this));
        }
Пример #6
0
 public void DoWebplayerLogin(Roar.Callback <WebObjects.Facebook.LoginOauthResponse> callback)
 {
     if (oAuthToken == null || oAuthToken == "")
     {
         loginCB         = callback;
         postLoginAction = PostLogionAction.LoginRoar;
         AttemptFacebookLoginChain();
     }
     else
     {
         DoLoginFacebookOAuth(callback);
     }
 }
Пример #7
0
    public void testFetchSuccess()
    {
        bool callbackExecuted = false;

        Roar.Callback <IDictionary <string, Roar.DomainObjects.ShopEntry> > roarCallback = (Roar.CallbackInfo <IDictionary <string, Roar.DomainObjects.ShopEntry> > callbackInfo) => {
            callbackExecuted = true;
            Assert.AreEqual(IWebAPI.OK, callbackInfo.code);
            Assert.IsNotNull(callbackInfo.data);
        };
        mockFetch(shopList, roarCallback);
        Assert.IsTrue(callbackExecuted);
        Assert.IsTrue(shop.HasDataFromServer);
    }
Пример #8
0
    public void testFetchSuccess()
    {
        bool callbackExecuted = false;

        Roar.Callback <IDictionary <string, Roar.DomainObjects.PlayerAttribute> > roarCallback = (Roar.CallbackInfo <IDictionary <string, Roar.DomainObjects.PlayerAttribute> > callbackInfo) => {
            callbackExecuted = true;
            Assert.AreEqual(IWebAPI.OK, callbackInfo.code);
            Assert.IsNotNull(callbackInfo.data);
        };
        mockFetch(userView, roarCallback);
        Assert.IsTrue(callbackExecuted);
        Assert.IsTrue(properties.HasDataFromServer);
    }
Пример #9
0
    //TODO: Should this take Roar.Callback<CT> instead?a
    public bool Fetch(Roar.Callback <IDictionary <string, CT> > cb, Hashtable p, bool persist)
    {
        // Bail out if call for this Model is already underway
        if (this.isServerCalling)
        {
            return(false);
        }

        getter.get(new OnFetch(cb, this));

        this.isServerCalling = true;
        return(true);
    }
Пример #10
0
        public void ChangeName(string name, Roar.Callback <WebObjects.User.ChangeNameResponse> cb)
        {
            if (name == "")
            {
                logger.DebugLog("[roar] -- Must specify name for ChangeName");
                return;
            }

            WebObjects.User.ChangeNameArguments args = new Roar.WebObjects.User.ChangeNameArguments();
            args.name = name;

            userActions.change_name(args, new CBBase <WebObjects.User.ChangeNameResponse> (cb));
        }
Пример #11
0
        public void AcceptFriendInvite(string friends_id, string invite_id, Roar.Callback <WebObjects.Friends.AcceptResponse> cb)
        {
            if (friends_id == "" || invite_id == "")
            {
                logger.DebugLog("[roar] -- Must specify friends_id and invite_id for accepting a friend invite.");
                return;
            }

            WebObjects.Friends.AcceptArguments args = new WebObjects.Friends.AcceptArguments();
            args.friends_id = friends_id;
            args.invite_id  = invite_id;
            friendsActions.accept(args, new AcceptFriendsCallback(cb));
        }
Пример #12
0
        // ---- Access Methods ----
        // ------------------------

        public void Login(string name, string hash, Roar.Callback <WebObjects.User.LoginResponse> cb)
        {
            if (name == "" || hash == "")
            {
                logger.DebugLog("[roar] -- Must specify username and password for login");
                return;
            }

            WebObjects.User.LoginArguments args = new WebObjects.User.LoginArguments();
            args.name = name;
            args.hash = hash;
            userActions.login(args, new LoginCallback(cb, this));
        }
Пример #13
0
        // ---- Access Methods ----
        // ------------------------

        public void Login(string code, string google_client_id, Roar.Callback <WebObjects.Google.LoginUserResponse> cb)
        {
            if (code == "")
            {
                logger.DebugLog("[roar] -- Must specify code for google login");
                return;
            }

            Roar.WebObjects.Google.LoginUserArguments args = new Roar.WebObjects.Google.LoginUserArguments();
            args.code             = code;
            args.google_client_id = google_client_id;

            google.login_user(args, new LoginUserCallback(cb));
        }
Пример #14
0
        public void CreateOAuth(string name, string oAuthToken, Roar.Callback <WebObjects.Facebook.CreateOauthResponse> cb)
        {
            if (name == "" || oAuthToken == "")
            {
                logger.DebugLog("[roar] -- Must specify username and oauthToken for creation");
                return;
            }

            Roar.WebObjects.Facebook.CreateOauthArguments args = new Roar.WebObjects.Facebook.CreateOauthArguments();
            args.name        = name;
            args.oauth_token = oAuthToken;

            facebook.create_oauth(args, new CreateOAuthCallback(cb));
        }
Пример #15
0
 public void DoWebplayerBind(Roar.Callback <WebObjects.Facebook.BindOauthResponse> cb)
 {
     if (oAuthToken == null || oAuthToken == "")
     {
         requestedBindCB = cb;
         postLoginAction = PostLogionAction.BindRoar;
         AttemptFacebookLoginChain();
     }
     else
     {
         Roar.WebObjects.Facebook.BindOauthArguments args = new Roar.WebObjects.Facebook.BindOauthArguments();
         args.oauth_token = oAuthToken;
         facebook.bind_oauth(args, new FacebookBindCallback(cb, this));
     }
 }
Пример #16
0
        public void Unequip(string id, Roar.Callback <Roar.WebObjects.Items.UnequipResponse> callback)
        {
            var item = dataStore.inventory.Get(id as string);

            if (item == null)
            {
                logger.DebugLog("[roar] -- Failed: no record with id: " + id);
                return;
            }

            WebObjects.Items.UnequipArguments args = new Roar.WebObjects.Items.UnequipArguments();
            args.item_id = id;

            itemActions.unequip(args, new UnequipCallback(callback, this, id));
        }
Пример #17
0
        public void RemoveFriend(string friend_id, string player_id, Roar.Callback <WebObjects.Friends.RemoveResponse> cb)
        {
            if (friend_id == "")
            {
                logger.DebugLog("[roar] -- Must specify friend_id for removing a friend.");
            }
            if (player_id == "")
            {
                logger.DebugLog("[roar] -- Must specify player_id for removing a friend.");
            }

            WebObjects.Friends.RemoveArguments args = new WebObjects.Friends.RemoveArguments();
            args.friend_id = friend_id;
            args.player_id = player_id;
            friendsActions.remove(args, new RemoveFriendCallback(cb));
        }
Пример #18
0
    public void TestRemoveFriend()
    {
        string remove_result = "<roar tick='123'><friends><remove status='ok'/></friends></roar>";

        requestSender.addMockResponse("friends/remove", remove_result);
        Roar.Callback <Roar.WebObjects.Friends.RemoveResponse> cb = (Roar.CallbackInfo <Roar.WebObjects.Friends.RemoveResponse> info) => {
            Assert.IsNotNull(info.data);
        };
        friends.RemoveFriend("123", "345", cb);

        remove_result = "<roar tick='123'><friends><remove status='error'><error/></remove></friends></roar>";
        requestSender.addMockResponse("friends/remove", remove_result);
        cb = (Roar.CallbackInfo <Roar.WebObjects.Friends.RemoveResponse> info) => {
            Assert.IsNull(info.data);
        };
        friends.RemoveFriend("123", "234", cb);
    }
Пример #19
0
    public void TestAcceptFriend()
    {
        string accept_result = "<roar tick='123'><friends><accept status='ok'/></friends></roar>";

        requestSender.addMockResponse("friends/accept", accept_result);
        Roar.Callback <Roar.WebObjects.Friends.AcceptResponse> cb = (Roar.CallbackInfo <Roar.WebObjects.Friends.AcceptResponse> info) => {
            Assert.IsNotNull(info.data);
        };
        friends.AcceptFriendInvite("123", "456", cb);

        accept_result = "<roar tick='123'><friends><accept status='error'><error type='0'></error></accept></friends></roar>";
        requestSender.addMockResponse("friends/accept", accept_result);
        cb = (Roar.CallbackInfo <Roar.WebObjects.Friends.AcceptResponse> info) => {
            Assert.IsNull(info.data);
        };
        friends.AcceptFriendInvite("123", "456", cb);
    }
Пример #20
0
        public void ShopBuy(string shop_ikey, Roar.Callback <WebObjects.Shop.BuyResponse> cb)
        {
            var shop_item = dataStore.shop.Get(shop_ikey);

            // Make the call if the item is in the shop
            if (shop_item == null)
            {
                logger.DebugLog("[roar] -- Cannot find to purchase: " + shop_ikey);
                return;
            }
            logger.DebugLog("trying to buy me a : " + shop_item.ikey + ":" + shop_item.label);

            WebObjects.Shop.BuyArguments args = new Roar.WebObjects.Shop.BuyArguments();
            args.shop_item_ikey = shop_item.ikey;

            shopActions.buy(args, new ShopBuyCallback(cb, this, shop_item.ikey));
        }
Пример #21
0
    public void TestDeclineFriend()
    {
        string decline_result = "<roar tick='123'><friends><decline status='ok'/></friends></roar>";

        requestSender.addMockResponse("friends/decline", decline_result);
        Roar.Callback <Roar.WebObjects.Friends.DeclineResponse> cb = (Roar.CallbackInfo <Roar.WebObjects.Friends.DeclineResponse> info) => {
            Assert.IsNotNull(info.data);
        };
        friends.DeclineFriendInvite("123", cb);

        decline_result = "<roar tick='123'><friends><decline status='error'><error/></decline></friends></roar>";
        requestSender.addMockResponse("friends/decline", decline_result);
        cb = (Roar.CallbackInfo <Roar.WebObjects.Friends.DeclineResponse> info) => {
            Assert.IsNull(info.data);
        };
        friends.DeclineFriendInvite("123", cb);
    }
Пример #22
0
        // ---- Data Methods ----
        // ----------------------
        // UNITY Note: Data is never coerced from a string to an Object(Hash)
        // which is left as an exercise for the reader
        public void load(string key, Roar.Callback <string> callback)
        {
            // If data is already present in the client cache, return that
            if (Data_[key] != null)
            {
                var ret = Data_[key] as string;
                if (callback != null)
                {
                    callback(new Roar.CallbackInfo <string>(ret, IWebAPI.OK, ret));
                }
            }
            else
            {
                WebObjects.User.NetdriveFetchArguments args = new Roar.WebObjects.User.NetdriveFetchArguments();
                args.ikey = key;

                user_actions_.netdrive_fetch(args, new OnGetData(callback, this, key));
            }
        }
Пример #23
0
        /**
         * Fetches details about `items` array and adds to item Cache Model
         */
        public bool AddToCache(IList <string> items, Roar.Callback <IDictionary <string, DomainObjects.ItemPrototype> > cb)
        {
            IList <string> batch = ItemsNotInCache(items);

            // Make the call if there are new items to fetch,
            // passing the `batch` list and persisting the Model data (adding)
            // Returns `true` if items are to be added, `false` if nothing to add
            if (batch.Count > 0)
            {
                var       keysAsJSON = Roar.Json.ArrayToJSON(batch);
                Hashtable args       = new Hashtable();
                args ["item_ikeys"] = keysAsJSON;
                Fetch(cb, args, true);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #24
0
    // Preps the data from server and places it within the Model
    // Not clear whether this should ammend or replace the data
    // At the moment it ammends!
    private void ProcessData(DT d, Roar.Callback <IDictionary <string, CT> > cb)
    {
        Dictionary <string, CT> o = converter.convert(d);

        // Flag server cache called
        // Must do before `set()` to flag before change events are fired
        HasDataFromServer = true;

        // Update the Model
        this.Set(o);
        if (cb != null)
        {
            cb(new Roar.CallbackInfo <IDictionary <string, CT> >(o, WebAPI.OK, null));
        }

        logger.DebugLog("Setting the model in " + name + " to : " + Roar.Json.ObjectToJSON(o));
        logger.DebugLog("[roar] -- Data Loaded: " + name);

        // Broadcast data ready event
        RoarManager.OnComponentReady(this.name);
    }
Пример #25
0
        public void DoWebplayerCreate(string name, Roar.Callback <WebObjects.Facebook.CreateOauthResponse> cb)
        {
            if (oAuthToken == null || oAuthToken == "")
            {
                createoAuthCB   = cb;
                postLoginAction = PostLogionAction.CreateRoar;
                requestedName   = name;
                AttemptFacebookLoginChain();
            }
            else
            {
                if (name == "" || oAuthToken == "" || oAuthToken == null)
                {
                    logger.DebugLog("[roar] -- Must specify username and signed req for creation");
                    return;
                }

                Roar.WebObjects.Facebook.CreateOauthArguments args = new Roar.WebObjects.Facebook.CreateOauthArguments();
                args.name        = name;
                args.oauth_token = oAuthToken;
                facebook.create_oauth(args, new FacebookCreateCallback(cb, this));
            }
        }
Пример #26
0
        public void ChangePassword(string name, string new_password, string old_password, Roar.Callback <WebObjects.User.ChangePasswordResponse> cb)
        {
            if (name == "")
            {
                logger.DebugLog("[roar] -- Must specify name for ChangePassword");
                return;
            }
            if (new_password == "")
            {
                logger.DebugLog("[roar] -- Must specify new_password for ChangePassword");
                return;
            }
            if (old_password == "")
            {
                logger.DebugLog("[roar] -- Must specify old_password for ChangePassword");
                return;
            }

            WebObjects.User.ChangePasswordArguments args = new Roar.WebObjects.User.ChangePasswordArguments();
            args.name         = name;
            args.new_password = new_password;
            args.old_password = old_password;

            userActions.change_password(args, new CBBase <WebObjects.User.ChangePasswordResponse> (cb));
        }
Пример #27
0
 protected void mockFetch(string mockResponse, Roar.Callback <IDictionary <string, Roar.DomainObjects.PlayerAttribute> > cb)
 {
     requestSender.addMockResponse("user/view", mockResponse);
     properties.Fetch(cb);
 }
Пример #28
0
 public LogoutCallback(Roar.Callback <WebObjects.User.LogoutResponse> in_cb, User in_user) : base(in_cb)
 {
     user = in_user;
     cb   = in_cb;
 }
Пример #29
0
 public void Logout(Roar.Callback <WebObjects.User.LogoutResponse> cb)
 {
     WebObjects.User.LogoutArguments args = new Roar.WebObjects.User.LogoutArguments();
     userActions.logout(args, new LogoutCallback(cb, this));
 }
Пример #30
0
 public LoginCallback(Roar.Callback <WebObjects.User.LoginResponse> in_cb, User in_user) : base(in_cb)
 {
     user = in_user;
 }