Class: Client::ModularHandler

Inherits:
SimpleChannelInboundHandler
  • Object
show all
Includes:
Listenable
Defined in:
lib/client.rb

Overview

The ModularHandler class class ModularHandler < ChannelInboundHandlerAdapter

Constant Summary collapse

IdentiferTemplate =
'#<%<class>s:0x%<id>s>'.freeze

Instance Method Summary collapse

Methods included from Listenable

#add_listener, #listeners, #notify, #remove_listener, #replace_listeners

Instance Method Details

#channelActive(ctx) ⇒ Object



280
281
282
283
284
# File 'lib/client.rb', line 280

def channelActive(ctx)
  ::Client.log.debug "Channel active #{ctx.channel}"
  notify :channel_active, ctx
  super(ctx)
end

#channelInactive(ctx) ⇒ Object



286
287
288
289
290
# File 'lib/client.rb', line 286

def channelInactive(ctx)
  log.trace "##{__method__} channel: #{ctx.channel}"
  notify :channel_inactive, ctx
  super(ctx)
end

#channelRead(ctx, msg) ⇒ Object



297
298
299
300
301
# File 'lib/client.rb', line 297

def channelRead(ctx, msg)
  log.trace "##{__method__} channel: #{ctx.channel}, message: #{msg.inspect}"
  notify :channel_read, ctx, msg
  super(ctx, msg)
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 abstract void channelRead0(ChannelHandlerContext ctx, I msg) throws Exception’



307
308
309
310
# File 'lib/client.rb', line 307

def channelRead0(ctx, msg)
  log.trace "##{__method__} channel: #{ctx.channel}, message: #{msg.inspect}"
  messageReceived(ctx, msg)
end

#channelReadComplete(ctx) ⇒ Object



312
313
314
315
316
# File 'lib/client.rb', line 312

def channelReadComplete(ctx)
  log.trace "##{__method__} channel: #{ctx.channel}"
  notify :channel_read_complete, ctx
  super(ctx)
end

#channelRegistered(ctx) ⇒ Object



268
269
270
271
272
# File 'lib/client.rb', line 268

def channelRegistered(ctx)
  log.trace "##{__method__} channel: #{ctx.channel}"
  notify :channel_registered, ctx
  super(ctx)
end

#channelUnregistered(ctx) ⇒ Object



274
275
276
277
278
# File 'lib/client.rb', line 274

def channelUnregistered(ctx)
  log.trace "##{__method__} channel: #{ctx.channel}"
  notify :channel_unregistered, ctx
  super(ctx)
end

#channelWritabilityChanged(ctx) ⇒ Object



318
319
320
321
322
# File 'lib/client.rb', line 318

def channelWritabilityChanged(ctx)
  log.trace "##{__method__} channel: #{ctx.channel}"
  notify :channel_writability_changed, ctx
  super(ctx)
end

#exceptionCaught(ctx, cause) ⇒ Object



330
331
332
333
334
# File 'lib/client.rb', line 330

def exceptionCaught(ctx, cause)
  ::Client.log.warn "##{__method__} channel: #{ctx.channel}, cause: #{cause.message}"
  listeners = notify :exception_caught, ctx, cause
  super(ctx, cause) if listeners.empty?
end

#isSharableObject



264
265
266
# File 'lib/client.rb', line 264

def isSharable
  true
end

#messageReceived(ctx, msg) ⇒ Object



292
293
294
295
# File 'lib/client.rb', line 292

def messageReceived(ctx, msg)
  log.trace "##{__method__} channel: #{ctx.channel}, message: #{msg.inspect}"
  notify :message_received, ctx, msg
end

#to_sObject Also known as: inspect



338
339
340
# File 'lib/client.rb', line 338

def to_s
  format(IdentiferTemplate, class: self.class.name, id: object_id.to_s(16))
end

#userEventTriggered(ctx, evt) ⇒ Object



324
325
326
327
328
# File 'lib/client.rb', line 324

def userEventTriggered(ctx, evt)
  log.trace "##{__method__} channel: #{ctx.channel}, event: #{evt}"
  notify :user_event_triggered, ctx, evt
  super(ctx, evt)
end