Laravel中路由上的推送器未发送事件 [英] Pusher on route not sending event in Laravel

查看:63
本文介绍了Laravel中路由上的推送器未发送事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Pusher创建一个用于在Laravel 4上进行实时通知的测试应用. 在测试上述API时,我很难使其正常工作.

I am creating a test app using Pusher for real-time notification on Laravel 4. As I am testing the said API, I am having difficulties on making it work.

我在routes.php上有这个东西:

Route::get('pusher-test', function(){
    return View::make('pages.test');
});
Route::any('test', function(){
        $pusher = new Pusher('key','sect','app_key'); //my keys are correct.
        $pusher->trigger('notificationChannel', 'userRegistration', []);
});

然后创建我的pusherTest.js文件:

(function(){
    var pusher = new Pusher('key');
    var channel = pusher.subscribe('notificationChannel');
        channel.bind('userRegistration', function(data){
            $('.test').append('HEY!');
        }); 
})();

我的查看页面:

<html>
    <head>
        <meta charset="utf-8">
        {{ HTML::style('_/css/bootstrap.css') }}
        {{ HTML::style('_/css/mystyle.css') }}
    </head>
    <body>
        <h2>HI!</h2>
        <div class="test"></div>
        {{ HTML::script('_/js/bootstrap.js') }}
        {{ HTML::script('_/js/jquery.js') }}
        {{ HTML::script('_/js/pusher/pusher.min.js')}}
        {{ HTML::script('_/js/pusherTest.js')}}
    </body>
</html>

当我尝试在Pusher.com上观察我的应用程序的Debug Console时, 这是我看到的:

When I try to observe the Debug Console of my app on Pusher.com, here's what I see:

但是当我按下test路由时,它没有在Pusher应用程序上发送事件,也没有向我的客户端发送API消息.但是,如果我将在调试控制台上使用Create new Event测试器,请确保它足以发送API消息,并且我的客户端可以接收并更新它.

But when I hit the test route, it is not sending an event on my Pusher app, neither it sends the API message to my client. But if I will use the Create new Event tester on debug console, sure enough it sends the API message and my client receives and updates it.

您认为正在发生什么,为什么在我的路线上无法将事件发送到我的推送器应用程序?我无法弄清楚,因为没有异常错误.请指教.

What do you think is happening why on my route it can't send the event to my pusher app? I can't figure it out because is has no exception error. Please advice.

推荐答案

您可以在三个方面调试与Pusher的集成:

There are three points at which you can debug your integration with Pusher:

  1. 您与Pusher的HTTP(REST)API的交互
  2. 确保事件由Pusher使用Pusher调试控制台接收
  3. 通过检查pusher-js日志记录来确保客户端集成正常工作

在您所处的环境中,您已经完成了2.并且可以看到您触发的事件没有到达调试控制台.因此,您需要执行1.

In your situation you've done 2. and you can see the events you are triggering aren't reaching the debug console. So, you need to do 1.

Pusher PHP Server库提供了有关如何启用调试的详细信息: https://github.com/pusher/pusher-php-server#debugging

The Pusher PHP Server library provides details of how to enable debugging: https://github.com/pusher/pusher-php-server#debugging

以及如何从库中获取日志信息: https://github.com/pusher/pusher-php-server#logging

And how to get log information from the library: https://github.com/pusher/pusher-php-server#logging

一旦您拥有pusher-php-server库的日志记录信息,请随时发布它,以便我们了解问题所在,例如您是否收到非2xx的响应代码?

Once you have the pusher-php-server library logging information please feel free to post it so we can see what the problem may be e.g. are you getting a non 2xx response code?

这篇关于Laravel中路由上的推送器未发送事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆