コード例 #1
0
		public void ListenOn(EndPoint endPoint)
		{
			lock (_lockObject)
			{
				if (_isDisposed)
				{
					throw new ObjectDisposedException("StompServer");
				}
				var ipEndPoint = endPoint as IPEndPoint;
				if (ipEndPoint == null)
				{
					throw new ArgumentException("Cannot listen on endpoint: " + endPoint);
				}

				var listener = new StompListener {SpecifiedEndPoint = ipEndPoint};

				listener.ListenException += ListenerListenException;
				listener.ClientConnected += ListenerClientConnected;
				listener.StartListening();

				_listeners.Add(listener);
				_listenEndPoints.Add(listener.ListenEndPoint);

				// if this is the first endpoint added, start the cleanup timer
				if (_listeners.Count == 1)
				{
					_serverData.StartCleanupTimer();
				}
			}
		}
コード例 #2
0
		public void Test()
		{
			_listener = new StompListener();
			_listener.ClientConnected += ListenerClientConnected;
			_listener.StartListening();

			_clientTransport = new StompClientTransport
			          	{
			          		EndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), _listener.ListenEndPoint.Port)
			          	};
			_clientTransport.FrameReady += ClientFrameReady;
			_clientTransport.TransportException += ClientTransportException;
			_clientTransport.ConnectedChanged += ClientConnectedChanged;
			_clientTransport.Connect();

			if (Debugger.IsAttached)
			{
				_finishedEvent.WaitOne();
			}
			else
			{
				_finishedEvent.WaitOne(5000, true);
			}
			Assert.IsNull(_ex, "Exception encountered: " + _message + Environment.NewLine + _ex);
			Assert.AreEqual(_maxNumber, _number);
		}