Class: WebSocket::ClientChannelHandler
- Inherits:
-
SimpleChannelInboundHandler
- Object
- SimpleChannelInboundHandler
- WebSocket::ClientChannelHandler
- Includes:
- Listenable
- Defined in:
- lib/websocket_client.rb
Overview
The ClientChannelHandler class
Instance Attribute Summary collapse
-
#handshake_future ⇒ Object
readonly
Returns the value of attribute handshake_future.
Instance Method Summary collapse
- #channelActive(ctx) ⇒ Object
- #channelInactive(ctx) ⇒ Object
-
#channelRead0(ctx, msg) ⇒ Object
Please keep in mind that this method will be renamed to messageReceived(ChannelHandlerContext, I) in 5.0.
- #exceptionCaught(ctx, cause) ⇒ Object
- #handlerAdded(ctx) ⇒ Object
-
#initialize(handshaker) ⇒ ClientChannelHandler
constructor
A new instance of ClientChannelHandler.
- #messageReceived(ctx, msg) ⇒ Object
Methods included from Listenable
#add_listener, #listeners, #notify, #remove_listener, #replace_listeners
Constructor Details
#initialize(handshaker) ⇒ ClientChannelHandler
Returns a new instance of ClientChannelHandler.
305 306 307 308 |
# File 'lib/websocket_client.rb', line 305 def initialize(handshaker) super() @handshaker = handshaker end |
Instance Attribute Details
#handshake_future ⇒ Object (readonly)
Returns the value of attribute handshake_future.
303 304 305 |
# File 'lib/websocket_client.rb', line 303 def handshake_future @handshake_future end |
Instance Method Details
#channelActive(ctx) ⇒ Object
314 315 316 317 |
# File 'lib/websocket_client.rb', line 314 def channelActive(ctx) @handshaker.handshake(ctx.channel()) notify(:channelActive, ctx) end |
#channelInactive(ctx) ⇒ Object
319 320 321 |
# File 'lib/websocket_client.rb', line 319 def channelInactive(ctx) notify(:channelInactive, ctx) end |
#channelRead0(ctx, msg) ⇒ Object
Please keep in mind that this method will be renamed to messageReceived(ChannelHandlerContext, I) in 5.0.
java_signature ‘protected void channelRead0(ChannelHandlerContext ctx, I msg) throws Exception’
327 328 329 |
# File 'lib/websocket_client.rb', line 327 def channelRead0(ctx, msg) (ctx, msg) end |
#exceptionCaught(ctx, cause) ⇒ Object
337 338 339 340 341 |
# File 'lib/websocket_client.rb', line 337 def exceptionCaught(ctx, cause) cause.printStackTrace() @handshake_future.setFailure(cause) unless @handshake_future.isDone() ctx.close() end |
#handlerAdded(ctx) ⇒ Object
310 311 312 |
# File 'lib/websocket_client.rb', line 310 def handlerAdded(ctx) @handshake_future = ctx.newPromise() end |
#messageReceived(ctx, msg) ⇒ Object
331 332 333 334 335 |
# File 'lib/websocket_client.rb', line 331 def (ctx, msg) return finish_handshake(ctx, msg) unless @handshaker.isHandshakeComplete() (msg) notify(:messageReceived, ctx, msg) end |