Esempio n. 1
0
        public WoopsaJsonData WaitNotification(int subscriptionChannel, int lastNotificationId)
        {
            int channelId      = subscriptionChannel;
            int notificationId = lastNotificationId;
            WoopsaSubscriptionChannel channel;

            lock (_channels)
                if (_channels.ContainsKey(channelId))
                {
                    channel = _channels[channelId];
                }
                else
                {
                    channel = null;
                }
            if (channel != null)
            {
                IWoopsaNotifications notifications = channel.WaitNotification(WoopsaSubscriptionServiceConst.WaitNotificationTimeout, notificationId);
                return(WoopsaJsonData.CreateFromText(notifications.Serialize()));
            }
            else
            {
                throw new WoopsaInvalidSubscriptionChannelException(string.Format("Tried to call WaitNotification on channel with id={0} that does not exist", channelId));
            }
        }
Esempio n. 2
0
        public static string Serialize(this IWoopsaNotifications notifications)
        {
            StringBuilder builder = new StringBuilder();
            bool          first   = true;

            foreach (var notification in notifications.Notifications)
            {
                if (!first)
                {
                    builder.Append(MultipleElementsSeparator);
                }
                else
                {
                    first = false;
                }
                builder.Append(notification.Serialize());
            }
            return(String.Format(MultipleElementsFormat, builder.ToString()));
        }