我剛剛通過了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),我如何可以驗證該用戶,然後讓他/她訂閱了相應的通道?
感謝