Class: EventMachine::IRC::Dispatcher

Inherits:
Connection
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/em-irc/dispatcher.rb

Overview

EventMachine connection handler class that dispatches connections back to another object.

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Dispatcher

Returns a new instance of Dispatcher.

Raises:

  • (ArgumentError)


8
9
10
11
12
13
# File 'lib/em-irc/dispatcher.rb', line 8

def initialize(options)
  raise ArgumentError.new(":parent parameter is required for EM#connect") unless options[:parent]
  # TODO: if parent doesn't respond to a above methods, do a no-op
  @parent = options[:parent]
  @ssl    = options[:ssl] || false
end

Instance Method Details

#connection_completedObject



20
21
22
# File 'lib/em-irc/dispatcher.rb', line 20

def connection_completed
  @ssl ? start_tls : @parent.ready
end

#post_initObject



16
17
18
# File 'lib/em-irc/dispatcher.rb', line 16

def post_init
  @parent.conn = self
end

#ssl_handshake_completedObject



24
25
26
# File 'lib/em-irc/dispatcher.rb', line 24

def ssl_handshake_completed
  @parent.ready if @parent.ssl
end