コード例 #1
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();
        }