Class: Ponder::Connection

Inherits:
EventMachine::Connection
  • Object
show all
Includes:
EventMachine::Protocols::LineText2
Defined in:
lib/ponder/connection.rb

Instance Method Summary collapse

Constructor Details

#initialize(thaum) ⇒ Connection

Returns a new instance of Connection.



8
9
10
# File 'lib/ponder/connection.rb', line 8

def initialize(thaum)
  @thaum = thaum
end

Instance Method Details

#connection_completedObject



12
13
14
# File 'lib/ponder/connection.rb', line 12

def connection_completed
  @thaum.register
end

#receive_line(line) ⇒ Object



34
35
36
# File 'lib/ponder/connection.rb', line 34

def receive_line(line)
  @thaum.parse line
end

#unbindObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ponder/connection.rb', line 16

def unbind
  @thaum.connected = false
  @thaum.process_callbacks :disconnect, {}
  @thaum.logger.info '-- Ponder disconnected'
  @thaum.console_logger.info '-- Ponder disconnected'

  if @thaum.config.reconnect
    @thaum.logger.info "-- Reconnecting in #{@thaum.config.reconnect_interval} seconds"
    @thaum.console_logger.info "-- Reconnecting in #{@thaum.config.reconnect_interval} seconds"

    EventMachine::add_timer(@thaum.config.reconnect_interval) do
      reconnect @thaum.config.server, @thaum.config.port
    end
  else
    @thaum.logger.close
  end
end