HTML5 Websocket
我正在评估 PusherApp,并试图弄清楚这些事件是如何运作的。尚未在 .NET 中使用 Pusher 找到任何示例,但如果我说:
var socket = new Pusher(...)
socket.bind("onmessagecomplete", function(message){
//-- do something in here...
})
为了启动此操作,这是我需要以某种方式触发的 javascript 事件吗?当时我会做某种服务器端工作,然后我需要触发此事件,但不确定如何从服务器触发?我正在使用 C#。任何帮助都会很棒。
谢谢,
I'm evaluating PusherApp, and I'm trying to figure out how the events work. Haven't found any samples in .NET using Pusher but if I say:
var socket = new Pusher(...)
socket.bind("onmessagecomplete", function(message){
//-- do something in here...
})
For this to kick off, is this a javascript event I need to trigger somehow? I would be doing some sort of server side work at the time then I'll need to trigger this event but not sure how from the server? I'm using C#. Any help would be awesome.
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不会,当您收到来自 Pusher 的通知并且回调函数运行时,该事件会自动触发。它通过您调用
new Pusher()
时打开的 WebSocket 接收通知。在服务器上,您使用 REST API 将数据发送到 Pusher,然后将其推送到客户端和该 javascript回调被触发。
No, that event is automatically fired when you receive a notification from Pusher and your callback function is run. It receives the notifications via the WebSocket you opened when you called
new Pusher()
.On the server you use the REST API to send data to Pusher which it then pushes to the client and that javascript callback is fired.
onmessagecomplete
事件将由服务器端对 REST API 的调用触发(正如@andrew-marshall 指出的那样)。您可以使用用 C# 编写的 Pusher .NET REST 库 从 .NET 触发事件。这可以清楚地识别为服务器触发事件的原因是任何客户端事件都必须具有
client-
前缀。The
onmessagecomplete
event will be triggered from a server-side call to the REST API (as @andrew-marshall points out). You can trigger events from .NET using the Pusher .NET REST library which has been written in C#.The reason this can clearly be identified as a server triggered event is that any client events must have a
client-
prefix.