Esempio n. 1
0
        /// <summary>
        /// Unsubsctibes to presence events for a channel.
        /// </summary>
        /// <param name="key">The key for the channel.</param>
        /// <param name="channel">The name of the channel.</param>
        public void PresenceUnsubscribe(string key, string channel)
        {
            this.PresenceTrie.UnregisterHandler(channel);

            var request = new PresenceRequest();

            request.Key     = key;
            request.Channel = channel;
            request.Status  = false;
            request.Changes = false;

            this.Publish("emitter/", "presence", Encoding.UTF8.GetBytes(request.ToJson()));
        }
Esempio n. 2
0
        /// <summary>
        /// Subscribes to presence events. Optionaly requests a status of the channel.
        /// </summary>
        /// <param name="key">The key for the channel</param>
        /// <param name="channel">The name of the channel</param>
        /// <param name="status">Whether to request a status of the channel.</param>
        /// <param name="optionalHandler">A specific handler to receive presence events for this channel.</param>
        public void PresenceSubscribe(string key, string channel, bool status, PresenceHandler optionalHandler = null)
        {
            if (optionalHandler != null)
            {
                this.PresenceTrie.RegisterHandler(channel, optionalHandler);
            }

            var request = new PresenceRequest();

            request.Key     = key;
            request.Channel = channel;
            request.Status  = status;
            request.Changes = true;

            this.Publish("emitter/", "presence", Encoding.UTF8.GetBytes(request.ToJson()));
        }