lib/ruby_fs/stream.rb in ruby_fs-1.0.5 vs lib/ruby_fs/stream.rb in ruby_fs-1.1.0

- old
+ new

@@ -166,11 +166,11 @@ fire_event Event.new(headers, json_content_2_hash(content)) when 'command/reply', 'api/response' @command_callbacks.pop.call CommandReply.new(headers, (content == '' ? nil : content)) when 'auth/request' command "auth #{@secret}" do - async.command "event json ALL" if @events + async.command "event json #{event_mask}" if @events end when 'text/disconnect-notice' terminate else raise "Unknown request type received (#{headers.inspect})" @@ -179,16 +179,22 @@ def json_content_2_hash(content) json = JSON.parse content {}.tap do |hash| json.each_pair do |k, v| - hash[k.downcase.gsub(/-/,"_").intern] = v + hash[k.downcase.gsub('-',"_").intern] = v end end end def post_init @state = :started fire_event Connected.new + end + + def event_mask + return 'ALL' if @events == true + + Array(@events).join(' ') end end end