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); }
private void DisconnectAndReconnect() { using (Lock.Lock()) { if (_transport != null) { UnsubscribeTransportEvents(); _transport.Dispose(); _transport = null; } _waitingForConnectedFrame = false; _sendInProgress = false; } // call this without a lock, as it has its own lock and // releases it for callbacks CheckConnected(); using (Lock.Lock()) { if (_transport == null) { _transport = new StompClientTransport(); SubscribeTransportEvents(); _transport.Connect((IPEndPoint) RemoteEndPoint); } } }
public void ConnectTo(EndPoint endPoint) { Verify.ArgumentNotNull(endPoint, "endPoint"); using (Lock.Lock()) { CheckDisposed(); if (_transport != null) { Log.Warn("ConnectTo already called"); return; } // the only kind of transport we handle at the moment IPEndPoint ipEndPoint = (IPEndPoint) endPoint; RemoteEndPoint = endPoint; _transport = new StompClientTransport(); SubscribeTransportEvents(); _transport.Connect(ipEndPoint); } }
public void Dispose() { using (Lock.Lock()) { if (!_isDisposed) { _isDisposed = true; UnsubscribeTransportEvents(); if (_transport != null) { _transport.Shutdown(); _transport.Dispose(); _transport = null; } _incomingHeartBeatTimer.Dispose(); _outgoingHeartBeatTimer.Dispose(); _connectTimer.Dispose(); _connected = false; _waitingForConnectedFrame = false; foreach (var pair in _subscriptions) { var subscription = pair.Value; subscription.StateChanged -= SubscriptionStateChanged; subscription.Dispose(); } _subscriptions.Clear(); ConnectedChanged = null; } } }