/// <summary> /// Finds the state transition handler. /// </summary> /// <param name="currentState">State of the current.</param> /// <param name="frame">The frame.</param> /// <returns></returns> /// <exception cref="IllegalStateTransitionException">if the state transition if not allowed</exception> private IStateAwareMethodListener FindStateTransitionHandler(AMQState currentState, AMQMethodBody frame) { Type clazz = frame.GetType(); if (_logger.IsDebugEnabled) { _logger.Debug("Looking for state transition handler for frame " + clazz); } IDictionary classToHandlerMap = (IDictionary)_state2HandlersMap[currentState]; if (classToHandlerMap == null) { // if no specialised per state handler is registered look for a // handler registered for "all" states return(FindStateTransitionHandler(AMQState.ALL, frame)); } IStateAwareMethodListener handler = (IStateAwareMethodListener)classToHandlerMap[clazz]; if (handler == null) { if (currentState == AMQState.ALL) { _logger.Debug("No state transition handler defined for receiving frame " + frame); Console.WriteLine(" *** No state transition handler defined for receiving frame " + frame); //KHC return(null); } else { // if no specialised per state handler is registered look for a // handler registered for "all" states return(FindStateTransitionHandler(AMQState.ALL, frame)); } } else { return(handler); } }
/// <summary> /// This method is called by the MINA dispatching thread. Note that it could /// be called before BlockForFrame() has been called. /// </summary> /// <param name="evt">the frame event</param> /// <returns>true if the listener has dealt with this frame</returns> /// <exception cref="AMQException"></exception> public bool MethodReceived(AMQMethodEvent evt) { AMQMethodBody method = evt.Method; try { bool ready = (evt.ChannelId == _channelId) && ProcessMethod(evt.ChannelId, method); if (ready) { _doneEvt = evt; _resetEvent.Set(); } return(ready); } catch (AMQException e) { Error(e); // we rethrow the error here, and the code in the frame dispatcher will go round // each listener informing them that an exception has been thrown throw e; } }
public abstract bool ProcessMethod(ushort channelId, AMQMethodBody frame);
public override bool ProcessMethod(ushort channelId, AMQMethodBody frame) { return(_expectedClass.IsInstanceOfType(frame)); }
public AMQMethodEvent(ushort channelId, AMQMethodBody method, AMQProtocolSession protocolSession) { _channelId = channelId; _method = method; _protocolSession = protocolSession; }