简体   繁体   English

从 javascript 触发 Pusher 事件

[英]Trigger Pusher event from javascript

I am using Pusher for real-time page update for my static JavaScript app.我正在使用Pusher为我的 static JavaScript 应用程序进行实时页面更新。 when i tried to invoke trigger event its not responding anythin.当我尝试调用触发事件时,它没有任何响应。 here is my code这是我的代码

var pusher = new Pusher('5f5ebdf0612fbafff349');  
var myChannel = pusher.subscribe('channel_1')  
myChannel.trigger("say_hello", {'name':"Jai", 'age':22});

You can only trigger events Using JS ( It is not advisable until you clearly know what you are doing) once you have a subscription successfully registered with Pusher for Client Side Triggers.只有在 Pusher 为客户端触发器成功注册订阅后,才能使用 JS 触发事件(除非您清楚地知道自己在做什么,否则不建议这样做)。

It is important that you apply additional care when binding to client- prefixed events, since these originate from other users (client side), and could be subject to tampering by a malicious user of your site (any one can modify and execute your JS).在绑定到以客户端为前缀的事件时,请务必格外小心,因为这些事件来自其他用户(客户端),并且可能会被您站点的恶意用户篡改(任何人都可以修改和执行您的 JS) .

Read this for getting acces to client side event triggering: http://pusher.com/docs/client_api_guide/client_events#trigger-events阅读本文以获取对客户端事件触发的访问权限: http://pusher.com/docs/client_api_guide/client_events#trigger-events

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM