Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 推送器专用通道订阅成功回调数据_Javascript_Ajax_Publish Subscribe_Pusher - Fatal编程技术网

Javascript 推送器专用通道订阅成功回调数据

Javascript 推送器专用通道订阅成功回调数据,javascript,ajax,publish-subscribe,pusher,Javascript,Ajax,Publish Subscribe,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.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);

});
但当我在私人频道上尝试同样的方法时:

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\"}"}

请尝试绑定到此事件

'pusher_internal:subscription_succeeded'

pusher:subscription\u Successed事件在收到pusher\u internal:subscription\u Successed事件后触发。不同的事件名称用于区分公共事件和内部事件。

感谢您的建议,但在我绑定该事件时,似乎不会为我解雇它。