0

pusher-client ruby​​gem 在订阅公共频道时工作正常,但是当我尝试订阅 Presence 或 Private Channel 时,它会抛出“ArgumentError:错误数量的参数(2 比 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
4

1 回答 1

0

需要指定 pusher-client repo 的 git URL 才能订阅存在和私有频道。似乎已发布的 pusher-client gem 尚未使用对 repo 的最新提交进行更新。

gem 'pusher-client', :git => "git://github.com/logankoester/pusher-client.git"

除此之外,指定主 repo 的 fork 将使 :user_info 选项在订阅中传递:

gem 'pusher-client', :git => "git://github.com/agileanimal/pusher-client.git"
于 2012-05-17T21:00:33.040 回答