Exemplo n.º 1
0
		private void ServerStatusCallback(object state)
		{
			List<ServerSideSession> sessions;
			List<MessageQueue> messageQueues;

			using (_lockObject.Lock())
			{
				if (_serverStatusMessageQueue == null)
				{
					return;
				}

				sessions = new List<ServerSideSession>(_sessions.Values);
				messageQueues = new List<MessageQueue>(_messageQueues.Values);
			}

			// need to be unlocked to perform this, otherwise we could deadlock


			var message = new ServerStatusMessage
			              	{
			              		MessageQueues = new List<MessageQueueStatus>(),
			              		Sessions = new List<SessionStatus>(),
			              	};

			foreach (var session in sessions)
			{
				var status = session.CreateSessionStatus();
				message.Sessions.Add(status);
			}
			foreach (var messageQueue in messageQueues)
			{
				var status = messageQueue.CreateStatus();
				message.MessageQueues.Add(status);
			}

			var frame = new StompFrame(StompCommand.Message);
			frame.Serialize(message);
			frame.SetExpires(_config.ServerStatusPeriod);

			MessageQueue queue;
			using (_lockObject.Lock())
			{
				queue = _serverStatusMessageQueue;
			}

// ReSharper disable ConditionIsAlwaysTrueOrFalse
			if (queue != null)
// ReSharper restore ConditionIsAlwaysTrueOrFalse
			{
				queue.PublishFrame(frame);
				_serverStatusTimer.Change(_config.ServerStatusPeriod, TimeSpan.FromMilliseconds(-1));
			}
		}
Exemplo n.º 2
0
		private void HandleServerStatusMessage(ServerStatusMessage msg)
		{
		}