Class: Goat::NotificationCenter::Receiver

Inherits:
EM::Connection
  • Object
show all
Includes:
EM::P::LineText2
Defined in:
lib/goat/notifications.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.start(host, port) ⇒ Object



8
9
10
11
12
13
# File 'lib/goat/notifications.rb', line 8

def self.start(host, port)
  EM.connect(host, port, self)
rescue RuntimeError => e
  Goat.log :live, "Couldn't connect to notification server at #{host}:#{port}"
  raise e
end

Instance Method Details

#receive_line(line) ⇒ Object



15
16
17
# File 'lib/goat/notifications.rb', line 15

def receive_line(line)
  NotificationCenter.receive(line)
end

#unbindObject



19
20
21
22
23
24
# File 'lib/goat/notifications.rb', line 19

def unbind
  Goat.logw "Lost notification server connection"
  EM.add_timer(1) do
    NotificationCenter.start_receiver
  end
end