Class: Client::ModularHandler

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

Overview

The ModularHandler class

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



289
290
291
292
293
# File 'lib/tcp_server/client.rb', line 289

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

#channelInactive(ctx) ⇒ Object



295
296
297
298
299
# File 'lib/tcp_server/client.rb', line 295

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

#channelRead(ctx, msg) ⇒ Object



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

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



316
317
318
319
# File 'lib/tcp_server/client.rb', line 316

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

#channelReadComplete(ctx) ⇒ Object



321
322
323
324
325
# File 'lib/tcp_server/client.rb', line 321

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

#channelRegistered(ctx) ⇒ Object

rubocop: enable Naming/PredicateMethod



277
278
279
280
281
# File 'lib/tcp_server/client.rb', line 277

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

#channelUnregistered(ctx) ⇒ Object



283
284
285
286
287
# File 'lib/tcp_server/client.rb', line 283

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

#channelWritabilityChanged(ctx) ⇒ Object



327
328
329
330
331
# File 'lib/tcp_server/client.rb', line 327

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

#exceptionCaught(ctx, cause) ⇒ Object



339
340
341
342
343
# File 'lib/tcp_server/client.rb', line 339

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

#isSharableObject

Overrides the Java::IoNettyChannel::SimpleChannelInboundHandler#isSharable method rubocop: disable Naming/PredicateMethod



272
273
274
# File 'lib/tcp_server/client.rb', line 272

def isSharable
  true
end

#messageReceived(ctx, msg) ⇒ Object



301
302
303
304
# File 'lib/tcp_server/client.rb', line 301

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



347
348
349
# File 'lib/tcp_server/client.rb', line 347

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

#userEventTriggered(ctx, evt) ⇒ Object



333
334
335
336
337
# File 'lib/tcp_server/client.rb', line 333

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