lib/logstash/outputs/websocket.rb in logstash-lite-0.2.20101222161646 vs lib/logstash/outputs/websocket.rb in logstash-lite-0.2.20110112115019
- old
+ new
@@ -1,13 +1,11 @@
-require "logstash/outputs/base"
require "em-websocket" # rubygem 'em-websocket'
+require "logstash/namespace"
+require "logstash/outputs/base"
class LogStash::Outputs::Websocket < LogStash::Outputs::Base
- def initialize(url, config={}, &block)
- super
- end
-
+ public
def register
@channel = EventMachine::Channel.new
@subscribers = 0
@url.host = (@url.host or "0.0.0.0")
@url.port = (@url.port or 3232)
@@ -25,14 +23,15 @@
end # ws.onclose
end # ws.onopen
end
end # def register
+ public
def receive(event)
# Only publish the event to websockets if there are subscribers
# TODO(sissel): send a patch to eventmachine to fix this.
if @subscribers > 0
@logger.info("Sending event to websocket.")
@channel.push event.to_json
end
- end # def event
+ end # def receive
end # class LogStash::Outputs::Websocket