Esempio n. 1
0
    public void Update()
    {
        if (Input.GetKeyDown(KeyCode.C))
        {
            Debug.Log("Connecting ...");
            ddpConnection.Connect();
        }

        if (Input.GetKeyDown(KeyCode.V))
        {
            Debug.Log("Closing connection ...");
            ddpConnection.Close();
        }

        if (Input.GetKeyDown(KeyCode.S))
        {
            friendSub         = ddpConnection.Subscribe("friends");
            friendSub.OnReady = (Subscription obj) => {
                Debug.Log("Ready subscription: " + obj.id);
            };
        }

        if (Input.GetKeyDown(KeyCode.U))
        {
            ddpConnection.Unsubscribe(friendSub);
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            ddpConnection.Call("friends.removeAll");
        }

        if (Input.GetKeyDown(KeyCode.F))
        {
            MethodCall methodCall = ddpConnection.Call("friends.create", JSONObject.CreateStringObject("Coco"));
            methodCall.OnUpdated = (MethodCall obj) => {
                Debug.Log("Updated, methodId=" + obj.id);
            };
            methodCall.OnResult = (MethodCall obj) => {
                Debug.Log("Result = " + obj.result);
            };
        }

        if (Input.GetKeyDown(KeyCode.A))
        {
            MethodCall methodCall = ddpConnection.Call("friends.add", JSONObject.Create(7), JSONObject.Create(5));
            methodCall.OnUpdated = (MethodCall obj) => {
                Debug.Log("Updated, methodId=" + obj.id);
            };
            methodCall.OnResult = (MethodCall obj) => {
                Debug.Log("Result = " + obj.result);
            };
        }
    }
Esempio n. 2
0
        public void ShouldHandleMethod()
        {
            string id         = "ShouldHandleMethod";
            string methodName = "MethodName";
            int    parameter  = 5;

            _connection.IdGenerator = () => id;

            _connection.Call(methodName, parameter);

            _mock.Verify(webSocket => webSocket.SendJson(It.Is <MethodModel>(model => model.Id == id)));
        }
Esempio n. 3
0
        void InitData()
        {
            _client.Call("organization.getByUserID", (response) => {
                if (response.HasError())
                {
                    Debug.Log("[Organization] | Error | " + response.Error.Error);
                }

                Organization = response.Get <OrganizationCollection>();

                _client.Call("subscription.get", (subscriptionReponse) => {
                    if (response.HasError())
                    {
                        Debug.Log("[Subscription] | Error | " + response.Error.Error);
                    }

                    Subscription = subscriptionReponse.Get <SubscriptionCollection>();

                    _client.Call("quota.get", (quotaReponse) => {
                        if (response.HasError())
                        {
                            Debug.Log("[Quota] | Error | " + response.Error.Error);
                        }

                        Quota      = quotaReponse.Get <QuotaCollection>();
                        QuotaReady = true;
                    }, Organization._id, Subscription.quotaID);
                }, Organization._id, Organization.subscriptionID);

                _client.Call("storage.get", (storageResponse) => {
                    if (storageResponse.HasError())
                    {
                        Debug.Log("[Storage] | Error | " + storageResponse.Error.Error);
                    }

                    Storage      = storageResponse.Get <StorageCollection>();
                    StorageReady = true;

                    _client.Call("region.get", (regionResponse) => {
                        if (response.HasError())
                        {
                            Debug.Log(response.Error.Error);
                        }

                        Region      = regionResponse.Get <RegionCollection>();
                        RegionReady = true;
                    }, Storage.regionID);
                }, Organization._id, Organization.storage.storageID);

                _client.Call("applications.getAll", (applicationReponse) => {
                    if (applicationReponse.HasError())
                    {
                        Debug.Log("[Application] | Error | " + applicationReponse.Error.Error);
                    }

                    Applications     = applicationReponse.Get <ApplicationCollection[]>();
                    ApplicationReady = true;
                }, Organization._id);
            });
        }
Esempio n. 4
0
    public void Update()
    {
        if (Input.GetKeyDown(KeyCode.C))
        {
            Debug.Log("Connecting ...");
            ddpConnection.Connect();
        }

        if (Input.GetKeyDown(KeyCode.V))
        {
            ddpConnection.Close();
        }

        if (Input.GetKeyDown(KeyCode.S))
        {
            friendSub         = ddpConnection.Subscribe("friends");
            friendSub.OnReady = (Subscription obj) => {
                Debug.Log("Ready subscription: " + obj.id);
            };
        }

        if (Input.GetKeyDown(KeyCode.U))
        {
            ddpConnection.Unsubscribe(friendSub);
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            ddpConnection.Call("friends.removeAll");
        }

        if (Input.GetKeyDown(KeyCode.F))
        {
            ddpConnection.Call("friends.create", JSONObject.CreateStringObject("Coco"));
        }

        if (Input.GetKeyDown(KeyCode.D))
        {
            foreach (var entry in friendCollection.documents)
            {
                Debug.Log(entry.Key + " " + entry.Value);
            }
        }

        if (Input.GetKeyDown(KeyCode.O))
        {
            JSONObject parents = new JSONObject();
            parents.AddField("mother", "wonder woman");
            parents.AddField("father", "batman");
            JSONObject attr = new JSONObject();
            attr.AddField("age", 24);
            attr.AddField("height", 180);
            attr.AddField("parents", parents);
            ddpConnection.Call("friends.addAttributes", JSONObject.StringObject("Coco"), attr);
        }

        if (Input.GetKeyDown(KeyCode.P))
        {
            JSONObject attr = new JSONObject();
            attr.AddField("age", 1);
            attr.AddField("height", 1);
            attr.AddField("parents.mother", 1);
            ddpConnection.Call("friends.removeAttributes", JSONObject.StringObject("Coco"), attr);
        }
    }