【发布时间】:2011-02-23 18:32:54
【问题描述】:
我刚刚收到了 Pusherapp 的 hello world。现在我想创建私人频道,以便用户只阅读他们应该阅读的消息。
Pusher 文档仅提供了有关如何执行此操作的一些详细信息,我有点迷失了。
来自docs:
... Pusher JS 库被返回 连接时的 socket_id 推动者。
当它尝试订阅一个 私人频道,它发回一个 AJAX 向您的服务器请求 channel_name 和 socket_id 为 参数。
默认网址是 http://yourserver.com/pusher/auth。 ...
class PusherController < ApplicationController
def auth
if current_user
response = Pusher[params[:channel_name]].authenticate(params[:socket_id])
render :json => response
else
render :text => "Not authorized", :status => '403'
end
end
end
给定一个唯一的用户 ID (current_user.id),我如何验证该用户然后让他/她订阅相应的频道?
谢谢
【问题讨论】:
标签: ruby-on-rails ruby push