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
# 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]
end

Instance Method Details

#connection_completedObject



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

def connection_completed
  if @parent.ssl
    start_tls
  else
    @parent.ready
  end
end

#post_initObject



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

def post_init
  @parent.conn = self
  @parent.ready unless @parent.ssl
end

#ssl_handshake_completedObject



28
29
30
# File 'lib/em-irc/dispatcher.rb', line 28

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