Example #1
0
        public void Unsub(SubscriptionInfo subscriptionInfo)
        {
            if (subscriptionInfo == null)
            {
                throw new ArgumentNullException(nameof(subscriptionInfo));
            }

            if (!TryRemoveSubscription(subscriptionInfo))
            {
                return;
            }

            if (!IsConnected)
            {
                return;
            }

            ThrowIfDisposed();

            ThrowIfNotConnected();

            _connection.WithWriteLock((writer, arg) =>
            {
                UnsubCmd.Write(writer, arg.Id, arg.MaxMessages);
                writer.Flush();
            }, subscriptionInfo);
        }
Example #2
0
        private void DoSub(SubscriptionInfo subscriptionInfo) => _connection.WithWriteLock((writer, arg) =>
        {
            var sid = arg.Id.AsSpan();

            SubCmd.Write(writer, arg.Subject, sid, arg.QueueGroup);

            if (arg.MaxMessages.HasValue)
            {
                UnsubCmd.Write(writer, sid, arg.MaxMessages);
            }

            writer.Flush();
        }, subscriptionInfo);