Class: Telnet::ModularHandler

Inherits:
SimpleChannelInboundHandler
  • Object
show all
Includes:
Listenable
Defined in:
lib/telnet_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

Instance Method Details

#channelActive(ctx) ⇒ Object



279
280
281
282
283
# File 'lib/telnet_client.rb', line 279

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

#channelInactive(ctx) ⇒ Object



285
286
287
288
289
# File 'lib/telnet_client.rb', line 285

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

#channelRead(ctx, msg) ⇒ Object



296
297
298
299
300
# File 'lib/telnet_client.rb', line 296

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’



306
307
308
309
# File 'lib/telnet_client.rb', line 306

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

#channelReadComplete(ctx) ⇒ Object



311
312
313
314
315
# File 'lib/telnet_client.rb', line 311

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

#channelRegistered(ctx) ⇒ Object



267
268
269
270
271
# File 'lib/telnet_client.rb', line 267

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

#channelUnregistered(ctx) ⇒ Object



273
274
275
276
277
# File 'lib/telnet_client.rb', line 273

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

#channelWritabilityChanged(ctx) ⇒ Object



317
318
319
320
321
# File 'lib/telnet_client.rb', line 317

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

#exceptionCaught(ctx, cause) ⇒ Object



329
330
331
332
333
# File 'lib/telnet_client.rb', line 329

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

#isSharableObject



263
264
265
# File 'lib/telnet_client.rb', line 263

def isSharable
  true
end

#messageReceived(ctx, msg) ⇒ Object



291
292
293
294
# File 'lib/telnet_client.rb', line 291

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



337
338
339
# File 'lib/telnet_client.rb', line 337

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

#userEventTriggered(ctx, evt) ⇒ Object



323
324
325
326
327
# File 'lib/telnet_client.rb', line 323

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