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.



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

def initialize(thaum)
  @thaum = thaum
end

Instance Method Details

#connection_completedObject



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

def connection_completed
  @thaum.register
end

#receive_line(line) ⇒ Object



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

def receive_line(line)
  @thaum.parse line
end

#unbindObject



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

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

  if @thaum.config.reconnect
    @thaum.traffic_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
    EventMachine::stop_event_loop
  end
end