Exemple #1
0
        public IFrame Process(IStompClient client, IFrame request)
        {
            var id = request.Headers["id"];

            if (id == null)
            {
                throw new BadRequestException(request, "You must include the 'id' header in the SUBSCRIBE frame.");
            }

            if (client.SubscriptionExists(id))
            {
                throw new BadRequestException(request, string.Format("There is already a subscription with id '{0}'.", id));
            }

            var ackType = GetAckType(request);
            var queue   = GetQueue(request);

            var subscription = new Subscription(client, id)
            {
                AckType   = ackType,
                QueueName = queue.Name
            };

            queue.AddSubscription(subscription);
            client.AddSubscription(subscription);

            return(request.CreateReceiptIfRequired());
        }
        public IFrame Process(IStompClient client, IFrame request)
        {
            var id = request.Headers["id"];
            if (id == null)
                throw new BadRequestException(request, "You must include the 'id' header in the SUBSCRIBE frame.");

            if (client.SubscriptionExists(id))
                throw new BadRequestException(request, string.Format("There is already a subscription with id '{0}'.", id));

            var ackType = GetAckType(request);
            var queue= GetQueue(request);

            var subscription = new Subscription(client, id)
            {
                AckType = ackType,
                QueueName = queue.Name
            };

            queue.AddSubscription(subscription);
            client.AddSubscription(subscription);

            return request.CreateReceiptIfRequired();
        }