Pusher 应用程序事件未触发

发布于 2024-12-08 11:49:40 字数 736 浏览 0 评论 0原文

我正在使用 PHP 和 Javscript (jQuery) 使用一个相当简单的应用程序测试 Pusher 库来处理 websockets,您可以在这里找到它: http://jsfiddle.net/JyVvr/1/

后端 ajax.php 文件包含以下内容:

require 'lib/Pusher.php';

$message = $_POST['msg'];

$pusher = PusherInstance::get_pusher(); // My API key, secret, etc is directly set in the Pusher.php file

$pusher->trigger(
    'test_channel',
    'new_comment',
    array('message' => $message)
);

echo json_encode(array('message' => $message));

基本上,应用程序只是获取一条消息并将其附加到表单提交上的 ul 元素,附加部分工作正常,但 new_comment 事件未触发,因此应用程序未按预期工作,我使用警报只是为了测试它是否显示,但它什么也没做,而且它不会抛出任何错误或任何东西。谁能告诉我我做错了什么?

提前致谢!

I'm testing out the Pusher library for handling websockets with a rather simple app using PHP and Javscript (jQuery) you can find it here: http://jsfiddle.net/JyVvr/1/

Tha backend ajax.php file contains this:

require 'lib/Pusher.php';

$message = $_POST['msg'];

$pusher = PusherInstance::get_pusher(); // My API key, secret, etc is directly set in the Pusher.php file

$pusher->trigger(
    'test_channel',
    'new_comment',
    array('message' => $message)
);

echo json_encode(array('message' => $message));

Basically the app just takes a message and appends it to the ul element on form submit, the appending part works just fine but the new_comment event isn't triggering so the app isn't working as intended, I used an alert just to test if it showed but it just does nothing plus it doesn't throw any errors or anything. Can anyone tell me what am I doing wrong?

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

幽梦紫曦~ 2024-12-15 11:49:40

如果事件未到达 Pusher,请确保 Pusher 服务器时间和您的服务器时间匹配或相差在 599 秒以内。我最近一直在试图解决这个问题,而这篇文章是第一篇出现的文章,所以只是向其他人提及这一点,以节省他们的时间和头痛。

If the events aren't reaching Pusher, make sure the Pusher server time and your server time match or are within 599s of each other. I've been trying to figure this out recently and this article was the first one to appear, so just mentioning this for others to save them some time and headache.

请远离我 2024-12-15 11:49:40

查看您应用的 Pusher 调试控制台。如果您没有看到您的事件在那里被触发,那么它要么没有到达,要么没有被 Pusher REST API 接受。

没有任何关于此 Pusher PHP 库的问题

Take a look at the Pusher Debug Console for your app. If you don't see your event triggered in there then it's either not reaching or is not being accepted by the Pusher REST API.

There aren't any issued raised about this Pusher PHP library.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文