Cyclone SSE - 服务器事件广播服务器


未知
跨平台
Python

软件简介

Cyclone SSE 是一个 Server-Sent Events (EventSource) 广播服务器,基于
Cyclone Web 服务器构建。

安装:

virtualenv --no-site-packages env
. env/bin/activate
pip install cyclone-sse

客户端使用:

<!doctype html>
<meta charset=utf-8>
<title>Title</title>

<script>
    sse = new EventSource('http://127.0.0.1:8888/?channels=base')
    sse.addEventListener('message', function(e) {
        console.log("Got message", e.data)
    })

    /* Some helpful handler to have */
    sse.addEventListener('open', function(e) {
        console.info("Opened SSE connection")
    })
    sse.addEventListener('error', function(e) {
        console.error("Failed to open SSE connection")
    })
</script>