public void CloseSubscription(String subscriptionId)
        {
            BasicSubscription subscription = null;

            if (!IsConnected())
            {
                throw new Exception("not connected");
            }

            if (protocol < 1)
            {
                throw new NotSupportedException("close subscription is not supported with this server");
            }

            bool removed = subscriptions.TryRemove(subscriptionId, out subscription);

            if (removed && subscription != null)
            {
                JsonObject message = new JsonObject();

                message[ProtocolConstants.OP_FIELD]  = ProtocolOpConstants.OP_UNSUBSCRIBE;
                message[ProtocolConstants.ID_FIELD]  = subscription.getSubscriptionId();
                message[ProtocolConstants.DEL_FIELD] = "false";

                Queue(message.ToString());
            }
        }
示例#2
0
        public void Unsubscribe(String subscriptionId)
        {
            BasicSubscription subscription = null;

            if (!IsConnected())
            {
                throw new Exception("not connected");
            }

            if (subscriptions.ContainsKey(subscriptionId))
            {
                subscription = subscriptions[subscriptionId];
            }

            bool removed = subscriptions.Remove(subscriptionId);

            if (removed && subscription != null)
            {
                JsonObject message = new JsonObject();

                message[ProtocolConstants.OP_FIELD] = ProtocolOpConstants.OP_UNSUBSCRIBE;
                message[ProtocolConstants.ID_FIELD] = subscription.getSubscriptionId();

                Queue(message.ToString());
            }
        }
        private void Subscribe(String subscriptionId, String matcher, String durable, Hashtable props, ISubscriptionListener listener)
        {
            BasicSubscription subscription = new BasicSubscription(subscriptionId, matcher, durable, props, listener);

            subscriptions.TryAdd(subscription.getSubscriptionId(), subscription);

            Subscribe(subscription);
        }
示例#4
0
        private void Subscribe(String subscriptionId, String matcher, String durable, ISubscriptionListener listener)
        {
            BasicSubscription subscription = new BasicSubscription(subscriptionId, matcher, durable, listener);

            subscription.setPending(true);
            subscriptions.Add(subscription.getSubscriptionId(), subscription);

            Subscribe(subscription);
        }
示例#5
0
        private void Subscribe(BasicSubscription subscription)
        {
            JsonObject message = new JsonObject();

            message[ProtocolConstants.OP_FIELD] = ProtocolOpConstants.OP_SUBSCRIBE;
            message[ProtocolConstants.ID_FIELD] = subscription.getSubscriptionId();
            if (subscription.getContentMatcher() != null)
            {
                message[ProtocolConstants.MATCHER_FIELD] = subscription.getContentMatcher();
            }
            if (subscription.getDurable() != null)
            {
                message[ProtocolConstants.DURABLE_FIELD] = subscription.getDurable();
            }

            Queue(message.ToString());
        }