Class: Radiowaves::Transmitter

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/radiowaves/transmitter.rb

Instance Method Summary collapse

Methods included from Logging

#logger

Constructor Details

#initialize(host, port) ⇒ Transmitter

Returns a new instance of Transmitter.



8
9
10
# File 'lib/radiowaves/transmitter.rb', line 8

def initialize(host, port)
  @client = WebSocket.new("ws://#{host}:#{port}/")
end

Instance Method Details

#startObject



12
13
14
15
16
17
18
19
# File 'lib/radiowaves/transmitter.rb', line 12

def start
  ActiveSupport::Notifications.subscribe do |*args|
    event = ActiveSupport::Notifications::Event.new(*args)
    json_event = event.to_json
    logger.debug json_event
    @client.send json_event
  end
end