Method: Artoo::Api::DeviceEventClient#initialize

Defined in:
lib/artoo/api/device_event_client.rb

#initialize(connection, topic) ⇒ DeviceEventClient

Create new event client



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/artoo/api/device_event_client.rb', line 19

def initialize(connection, topic)
  @io = Reel::Response::Writer.new(connection.socket)

  connection.detach

  connection.respond(:ok, {
    'Content-Type' => 'text/event-stream',
    'Connection' => 'keep-alive',
    'Transfer-Encoding' => 'chunked',
    'Cache-Control' => 'no-cache'
  })

  subscribe(topic, :notify_event)
end