lib/pusher-client/socket.rb in pusher-client-0.5.0 vs lib/pusher-client/socket.rb in pusher-client-0.6.0
- old
+ new
@@ -21,11 +21,12 @@
@global_channel = Channel.new('pusher_global_channel')
@global_channel.global = true
@connected = false
@encrypted = options[:encrypted] || false
@logger = options[:logger] || PusherClient.logger
- @private_auth_method = options[:private_auth_method]
+ # :private_auth_method is deprecated
+ @auth_method = options[:auth_method] || options[:private_auth_method]
@cert_file = options[:cert_file]
@ws_host = options[:ws_host] || HOST
@ws_port = options[:ws_port] || WS_PORT
@wss_port = options[:wss_port] || WSS_PORT
@ssl_verify = options.fetch(:ssl_verify, true)
@@ -155,22 +156,22 @@
def is_presence_channel(channel_name)
channel_name.match(/^presence-/)
end
def get_private_auth(channel)
- if @private_auth_method.nil?
- string_to_sign = @socket_id + ':' + channel.name
- signature = hmac(@secret, string_to_sign)
- return "#{@key}:#{signature}"
- else
- return @private_auth_method.call(@socket_id, channel)
- end
+ return @auth_method.call(@socket_id, channel) if @auth_method
+
+ string_to_sign = @socket_id + ':' + channel.name
+ signature = hmac(@secret, string_to_sign)
+ "#{@key}:#{signature}"
end
def get_presence_auth(channel)
+ return @auth_method.call(@socket_id, channel) if @auth_method
+
string_to_sign = @socket_id + ':' + channel.name + ':' + channel.user_data
signature = hmac(@secret, string_to_sign)
- return "#{@key}:#{signature}"
+ "#{@key}:#{signature}"
end
# for compatibility with JavaScript client API
alias :subscribeAll :subscribe_all