我刚刚通过了Pusherapp的hello world。现在我想创建私人频道,以便用户只能阅读他们应该阅读的信息。带Pusherapp的私人频道(使用Rails)
Pusher文档只提供一些关于如何做到这一点的细节,而且我有点迷茫。
从docs:
... 推动JS库返回 一个socket_id当它连接到 推杆。
当它试图订阅 专用通道,它发回一个AJAX请求 与 CHANNEL_NAME您的服务器和socket_id为 参数。
默认的URL是 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),我如何可以验证该用户,然后让他/她订阅了相应的通道?
感谢