推送客户端rubygem在订阅公共频道时工作正常,但当我尝试订阅Presence或私有频道时,它正在抛出“ArgumentError:错误的参数数量(2 for 1)”。这会发生在其他人身上吗?
module PusherClientTest
require 'pusher-client'
PusherClient.logger = Logger.new(STDOUT)
options = { :secret => '12345' }
socket = PusherClient::Socket.new("54321", options)
USER_ID = 1
socket.subscribe('presence-TestChannel', USER_ID)
socket.bind('remark') do |data|
puts data
end
socket.connect
end
ree-1.8.7-2010.02 > PusherClientTest
ArgumentError: wrong number of arguments (2 for 1)
from /Users/Dev/Sites/test_app/app/models/pusher_client_test.rb:16:in `subscribe'
from /Users/Dev/Sites/test_app/app/models/pusher_client_test.rb:16
from /Users/Dev/.rvm/gems/ree-1.8.7-2010.02@test_app/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:406:in `load_without_new_constant_marking'
from /Users/Dev/.rvm/gems/ree-1.8.7-2010.02@test_app/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:406:in `load_file'
from /Users/Dev/.rvm/gems/ree-1.8.7-2010.02@test_app/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:547:in `new_constants_in'
from /Users/Dev/.rvm/gems/ree-1.8.7-2010.02@test_app/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:405:in `load_file'
from /Users/Dev/.rvm/gems/ree-1.8.7-2010.02@test_app/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:285:in `require_or_load'
from /Users/Dev/.rvm/gems/ree-1.8.7-2010.02@test_app/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:451:in `load_missing_constant'
from /Users/Dev/.rvm/gems/ree-1.8.7-2010.02@test_app/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:106:in `const_missing_not_from_s3_library'
from /Users/Dev/.rvm/gems/ree-1.8.7-2010.02@test_app/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing'
from /Users/Dev/.rvm/gems/ree-1.8.7-2010.02@test_app/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:118:in `const_missing'
from (irb):1
答案 0 :(得分:0)
需要指定pusher-client repo的git URL才能订阅在线状态&私人频道。似乎已发布的pusher-client gem尚未使用最新的repo更新进行更新。
gem 'pusher-client', :git => "git://github.com/logankoester/pusher-client.git"
除此之外,指定主仓库的分支将启用:user_info选项在订阅中传递:
gem 'pusher-client', :git => "git://github.com/agileanimal/pusher-client.git"