系统设计基础之长轮询、WebSocket、服务器发送事件(SSEs)协议
IT科技 2025-10-07 10:20:26
0

复制<script type="text/javascript"> if (!!window.EventSource) { var source = new EventSource(push); //打开连接 source.addEventListener(open,系统协议 function (evt) { // console.info("连接已经打开了"); }, false); //接收消息 source.addEventListener(message, function (evt) { console.info(evt.data); }); //错误消息,及关闭通知 source.addEventListener(error, function (evt) { // console.info(evt); }, false); } else { alert("浏览器不支持 SSE") } </script> 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.