dev*_*ull 4 javascript node.js express server-sent-events
我将node.js(Express)与服务器发送的事件一起使用.我想通过关闭sse HTTP连接来关闭事件流.鉴于以下功能:
router.get('/sse', function (req, res) {
});
Run Code Online (Sandbox Code Playgroud)
怎么能实现呢?
Кон*_*Ван 15
response.end();\nRun Code Online (Sandbox Code Playgroud)\n请求客户端启动 TCP 套接字连接终止序列。
\nresponse.set("Connection", "close"); // Note: this is an HTTP header.\nRun Code Online (Sandbox Code Playgroud)\n\xe2\x80\x9c嘿,我\xe2\x80\x99现在要挂断了,\xe2\x80\x99kay?\xe2\x80\x9d
\n
response.connection.end();\nRun Code Online (Sandbox Code Playgroud)\n\n\n\n
socket.end([data[, encoding]][, callback])半关闭套接字。即,它发送一个
\nFIN数据包。服务器可能仍会发送一些数据。请参阅
\nwritable.end()了解更多详情。
FIN甚至没有数据包。response.connection.destroy();\nRun Code Online (Sandbox Code Playgroud)\n\n\n\n
socket.destroy([error])确保此套接字上不再发生 I/O 活动。销毁流并关闭连接。
\n请参阅
\nwritable.destroy()了解更多详情。