Example #1
0
        protected override IPromise <JsonValue> PerformFacetCall(
            string facetName,
            string methodName,
            JsonArray arguments
            )
        {
            var promise = new Promise <JsonValue>();

            http.Post(
                app.Resolve <ApiUrl>().CallFacet(),
                new JsonObject()
                .Add("facetName", facetName)
                .Add("methodName", methodName)
                .Add("arguments", arguments)
                .Add("sessionId", SessionId)
                .Add("deviceId", DeviceIdRepository.GetDeviceId())
                .Add("device", DeviceIdRepository.GetDeviceInfo())
                .Add("gameToken", app.Preferences.GameToken)
                .Add("editorKey", app.Preferences.EditorKey)
                .Add("client", new JsonObject()
                     .Add("backendHash", app.Preferences.BackendHash)
                     .Add("frameworkVersion", FrameworkMeta.Version)
                     .Add("assetVersion", AssetMeta.Version)
                     .Add("buildGuid", Application.buildGUID)
                     .Add("versionString", Application.version)
                     ),
                response => {
                if (response.IsOk)
                {
                    HandleSuccessfulRequest(response, promise);
                }
                else
                {
                    HandleFailedRequest(response, promise);
                }
            }
                );

            return(promise);
        }
Example #2
0
        public void EndSubscriptions(IEnumerable <ChannelSubscription> subscriptions)
        {
            JsonArray channelsToUnsubscribe = new JsonArray();

            foreach (var sub in subscriptions)
            {
                bool lastForChannel = EndSubscription(sub);

                if (lastForChannel)
                {
                    channelsToUnsubscribe.Add(sub.ChannelName);
                }
            }

            if (channelsToUnsubscribe.Count > 0)
            {
                // NOTE: It's important that the callback will remain null,
                // since this request could be fired during disposal
                // and we cannot wait for the response then.
                // All sorts of unity errors would show up in the console.

                http.Post(
                    url.BroadcastingUnsubscribe(),
                    new JsonObject {
                    ["gameToken"]   = app.Preferences.GameToken,
                    ["editorKey"]   = app.Preferences.EditorKey,
                    ["buildGuid"]   = Application.buildGUID,
                    ["backendHash"] = app.Preferences.BackendHash,
                    ["sessionId"]   = sessionIdRepository.GetSessionId(),
                    ["channels"]    = channelsToUnsubscribe
                },
                    null // IMPORTANT! see the note above
                    );
            }

            CheckTunnelNeededness();
        }