简体   繁体   English

按服务器停止服务器发送的事件

[英]Stop server-sent events by server

When using server-sent events, how does server communicate to browser that there won't be more events and that it should close the sse connection? 使用服务器发送的事件时,服务器如何与浏览器通信,不会有更多事件,应该关闭sse连接?

Is this a part of the protocol or should this be implemented by passing hint in normal event to the client that it can close event source ? 这是协议的一部分还是应该通过在正常事件中将提示传递给客户端来实现它可以关闭事件源?

The server-sent events is yet another streaming technique which is one of ways of Comet . 服务器发送的事件是另一种流技术,它是Comet的一种方式 To stop streaming data, just close the connection in server. 要停止流数据,只需关闭服务器中的连接即可。 You don't need to let client call close method of EventSource instance. 您不需要让客户端调用EventSource实例的close方法。

FYI, the following links show that how Cettia streaming transport backed by server-sent events implements to close connection. 仅供参考,以下链接显示由服务器发送的事件支持的Cettia流传输如何实现关闭连接。 (Note that I'm an author of Cettia) (请注意,我是Cettia的作者)


Edit 编辑

For that issue, I added es.close within es.onerror . 对于那个问题,我在es.onerror中添加了es.close

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

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