【发布时间】:2015-07-03 22:14:03
【问题描述】:
在连接到私有 Pusher 通道后,我正在尝试从服务器发回数据。以下代码适用于出席频道:
this.presenceChannel = this.pusher.subscribe('presence-chat');
this.presenceChannel.bind('pusher:subscription_succeeded', function(data){
//I can access all of the data here as expected
console.log(data);
});
但是当我尝试使用私人频道的相同方法时:
this.privateChannel = this.pusher.subscribe('private-user');
this.privateChannel.bind('pusher:subscription_succeeded', function(data){
//This returns an empty Object {}
console.log(data);
});
有趣的是,在 POST 请求数据中,我可以看到我试图访问的数据,但我不知道为什么我不能像访问状态通道那样访问它:
{"auth":"a146722cb55df886314f:7326fb3e1c807a679b4d4d5e5742fddc121d5ec18f5f078d054962b0267972a4","channel_data"
:"{\"data\":\"test\"}"}
【问题讨论】:
标签: javascript ajax publish-subscribe pusher