示例#1
0
 private void CheckConnection(string token)
 {
     // auto-connect or reconnect if token has changed since last connect
     if (_stomp.StompClientStatus != EnumStompClientStatus.Connected ||
         (token != null && !token.Equals(_connectToken)))
     {
         if (_stomp.StompClientStatus == EnumStompClientStatus.Connected)
         {
             SecucardTrace.Info("Reconnect due token change.");
         }
         try
         {
             _stomp.Disconnect();
         }
         catch (Exception e)
         {
             // just log...
             SecucardTrace.Info("Error disconnecting. {0}", e);
         }
         Connect(token);
     }
 }
示例#2
0
        public void disconnecting_the_client_should_remove_all_traces()
        {
            Assert.That(_server.Queues, Is.Empty, "initial queue list should be empty");

            _client.Subscribe("reutel");
            Thread.Sleep(TimeSpan.FromSeconds(2));

            Assert.That(_server.Queues, Is.Not.Empty, "There should have been a queue called 'reutel'");

            _client.Disconnect();

            Thread.Sleep(TimeSpan.FromSeconds(2));

            Assert.That(_server.Queues, Is.Empty, "All queues should have been removed");
        }
示例#3
0
        /// <summary>
        /// Disconnects this instance.
        /// </summary>
        public void Disconnect()
        {
            try
            {
                if (_stompClient == null)
                {
                    return;
                }

                if (_stompClient.IsConnected)
                {
                    if (Log.IsInfoEnabled)
                    {
                        Log.Debug("Sending 'DISCONNECT' to server");
                    }

                    _stompClient.Disconnect();
                }
            }
            catch (Exception ex)
            {
                Log.Warn("Failed to close STOMP connection.", ex);
            }
        }