require 'faye/websocket'
require 'record_filters'
require 'load_param'
+require 'set'
# Patch in user, last_log_id and filters fields into the Faye::Websocket class.
module Faye
attr_accessor :user
attr_accessor :last_log_id
attr_accessor :filters
+ attr_accessor :sent_ids
end
end
lastid = nil
logs.limit(limit).each do |l|
- ws.send(l.as_api_response.to_json)
+ if ws.sent_ids.add?(l.id) != nil
+ ws.send(l.as_api_response.to_json)
+ end
lastid = l.id
count += 1
end
ws.user = current_user
ws.filters = []
ws.last_log_id = nil
+ ws.sent_ids = Set.new
# Subscribe to internal postgres notifications through @channel. This will
# call push_events when a notification comes through.