【问题标题】:Pusher: "Uncaught TypeError: Cannot call method 'scopedTo' of undefined" when authingPusher:“未捕获的 TypeError:无法调用未定义的方法 'scopedTo'”
【发布时间】:2012-02-23 11:27:45
【问题描述】:

我的应用程序控制器中有我的 app_key、密钥和秘密

我的 PusherController:

  def auth
    if current_user
      auth = Pusher[params[:channel_name]].authenticate(params[:socket_id],
        :user_id => current_user.id, # => required
        :user_info => { # => optional
          :name => current_user.name,
          :email => current_user.email
        }
      )
      render :json => auth
    else
      render :text => "Not authorized", :status => '403'
    end
  end

我的js

var pusher = new Pusher("key");
Pusher.channel_auth_endpoint = "/pusher/auth";
Pusher.channel_auth_transport = 'json';

channel = pusher.subscribe("presence-content_editing");

我很确定我遵循了http://pusher.com/docs/presence-1.6的指示

我只是对为什么会收到此错误感到困惑

this is the error :
Uncaught TypeError: Cannot call method 'scopedTo' of undefined
Pusher.Channel.PrivateChannel.authorizepusher.min.js:38
Pusher.subscribepusher.min.js:13
Pusher.subscribeAllpusher.min.js:12
connection.bind.bind.cpusher.min.js:10
a.emitpusher.min.js:17
jpusher.min.js:25
_machine.b.Machine.connectedPostpusher.min.js:29
apusher.min.js:19
c.transitionpusher.min.js:20
w

【问题讨论】:

    标签: javascript ruby pusher


    【解决方案1】:

    Presence 资源看起来已过时 - 我们需要将其删除。

    您应该使用最新版本的 Pusher JavaScript 库,您可以在这里找到:

    http://js.pusher.com/1.11/pusher.min.js

    并遵循authenticating users docs 中所述的身份验证。您拥有的服务器代码看起来不错。错误出现在您的客户端上,我希望更新 JavaScript 库可以解决它 - 我们没有收到任何关于此问题的支持请求。

    【讨论】:

    • 我会再次查看文档,但我 /am/ 使用的是那个版本的 pusher =\
    • 想通了,因为我有这个:Pusher.channel_auth_transport = 'json';
    • 所以,删除它,解决了问题
    • 啊!这就说得通了。没有json 身份验证传输。有效的传输是ajaxjsonpjsonp可用于跨域认证。
    【解决方案2】:

    删除这两行:

    Pusher.channel_auth_endpoint = "/pusher/auth";
    Pusher.channel_auth_transport = 'json';
    

    【讨论】:

      猜你喜欢
      • 2012-08-27
      • 1970-01-01
      • 2013-01-27
      • 1970-01-01
      • 2013-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多