private void Connected(StompFrame frame) { using (_lockObject.Lock()) { StartIncomingHeartBeatTimer(); if (frame.IsHeartBeat) { // nothing else to do } else if (frame.Command == StompCommand.Disconnect) { DisconnectWithoutLocking(); var keepSession = frame.GetBoolean(StompHeader.NonStandard.KeepSession, false); if (!keepSession) { _serverData.EndSession(_session); } _session = null; } else { try { // ReSharper disable PossibleNullReferenceException _session.ProcessFrame(frame); // ReSharper restore PossibleNullReferenceException } catch (Exception ex) { if (ex.IsCorruptedStateException()) { throw; } Log.Error(_logMessagePrefix + "Unexpected error handling " + frame.Command + " frame: " + ex.Message, ex); try { var errorFrame = StompFrameUtils.CreateErrorFrame("internal server error", frame); _transport.SendFrame(errorFrame); DisconnectWithoutLocking(); } catch (InvalidOperationException) { // Not ideal, but we can encounter a situation where the transport is shutting down, so if // we send anything it is going to throw and exception. Because we currently do not have an // API for checking this, we just handle the exception. } } } } }