Class: WebSocket::IdleStateUserEventHandler
- Inherits:
-
ChannelDuplexHandler
- Object
- ChannelDuplexHandler
- WebSocket::IdleStateUserEventHandler
- Defined in:
- lib/websocket/idle_state_user_event_handler.rb
Overview
The IdleStateUserEventHandler class specifies methods implementing what to do when the pipeline detects an idle channel.
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize ⇒ IdleStateUserEventHandler
constructor
A new instance of IdleStateUserEventHandler.
-
#userEventTriggered(ctx, evt) ⇒ Object
java_signature ‘public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception’.
Constructor Details
#initialize ⇒ IdleStateUserEventHandler
Returns a new instance of IdleStateUserEventHandler.
29 30 31 |
# File 'lib/websocket/idle_state_user_event_handler.rb', line 29 def initialize super() end |
Instance Method Details
#userEventTriggered(ctx, evt) ⇒ Object
java_signature ‘public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception’
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/websocket/idle_state_user_event_handler.rb', line 34 def userEventTriggered(ctx, evt) return unless evt.respond_to?(:state) case evt.state when IdleState::READER_IDLE return handle_idle_channel(ctx, evt) if respond_to?(:handle_idle_channel) = TextWebSocketFrame.new("\nDisconnecting idle session\n") ctx.writeAndFlush().sync ctx.close when IdleState::WRITER_IDLE ctx.writeAndFlush(PingMessage.new) end end |