class Travis::Client::Listener::Socket
def fetch_auth(*channels)
def fetch_auth(*channels) channels.select! { |c| signatures[c].nil? if c.start_with? 'private-' } signatures.merge! session.post_raw('/pusher/auth', :channels => channels, :socket_id => socket_id)['channels'] if channels.any? end
def get_private_auth(channel)
def get_private_auth(channel) fetch_auth(channel.name) signatures[channel.name] end
def handle_error(data)
def handle_error(data) code, message = data["code"], data["message"] if data.is_a? Hash message ||= data.inspect case code when 4100 then reconnect(1) when 4200, 4201, 4202 then reconnect else raise Travis::Client::Error, "Pusher error: %s (code: %p)" % [message, code] end end
def initialize(application_key, options = {})
def initialize(application_key, options = {}) @session = options.fetch(:session) @signatures = {} super bind('pusher:error') do |data| handle_error(data) end end
def reconnect(delay = nil)
def reconnect(delay = nil) disconnect if connected sleep delay if delay and delay > 0 connect end
def subscribe_all
def subscribe_all # bulk auth on connect fetch_auth(*channels.channels.keys) super end