private void SendSubscription(NatsSubscription subscription)
        {
            log.Debug(Resources.NatsMessagingProvider_SubscribingToSubject_Fmt, subscription, subscription.SubscriptionID);
            string formattedMessage = NatsCommand.FormatSubscribeMessage(subscription, subscription.SubscriptionID);

            log.Trace(Resources.NatsMessagingProvider_LogSent_Fmt, formattedMessage);
            Write(formattedMessage);
        }
        public void Subscribe(NatsSubscription subscription, Action <string, string> callback)
        {
            SendSubscription(subscription);

            lock (subscriptions)
            {
                if (false == subscriptions.Contains(subscription))
                {
                    subscriptions.Add(subscription);
                }

                int subscriptionID = subscription.SubscriptionID;
                if (false == subscriptionCallbacks.ContainsKey(subscriptionID))
                {
                    subscriptionCallbacks.Add(subscriptionID, new List <Action <string, string> >());
                }
                subscriptionCallbacks[subscriptionID].Add(callback);
            }
        }
Example #3
0
 public static string FormatSubscribeMessage(NatsSubscription subscription, int Sequence)
 {
     return(String.Format(CultureInfo.InvariantCulture, NatsCommandFormats.SubscribeFmt, subscription, Sequence));
 }
 private void SendSubscription(NatsSubscription subscription)
 {
     log.Debug(Resources.NatsMessagingProvider_SubscribingToSubject_Fmt, subscription, subscription.SubscriptionID);
     string formattedMessage = NatsCommand.FormatSubscribeMessage(subscription, subscription.SubscriptionID);
     log.Trace(Resources.NatsMessagingProvider_LogSent_Fmt, formattedMessage);
     Write(formattedMessage);
 }
        public void Subscribe(NatsSubscription subscription, Action<string, string> callback)
        {
            SendSubscription(subscription);

            lock (subscriptions)
            {
                if (false == subscriptions.Contains(subscription))
                {
                    subscriptions.Add(subscription);
                }

                int subscriptionID = subscription.SubscriptionID;
                if (false == subscriptionCallbacks.ContainsKey(subscriptionID))
                {
                    subscriptionCallbacks.Add(subscriptionID, new List<Action<string, string>>());
                }
                subscriptionCallbacks[subscriptionID].Add(callback);
            }
        }