用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/G1Joshi/Agent-Skills --skill sse命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | sse |
| description | Server-Sent Events one-way real-time. Use for live updates. |
SSE allow a web page to get updates from a server. Unlike WebSockets, SSEs are unidirectional (Server -> Client) and use standard HTTP.
// Client
const evtSource = new EventSource("/api/events");
evtSource.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log("Update:", data);
};
// Server (Express)
app.get("/api/events", (req, res) => {
// Headers to keep connection open
res.setHeader("Content-Type", "text/event-stream");
res.setHeader("Cache-Control", "no-cache");
res.setHeader("Connection", "keep-alive");
setInterval(() => {
// Format: "data: <payload>\n\n"
res.write(`data: ${JSON.stringify({ time: new Date() })}\n\n`);
}, 1000);
});
Plain text. Fields: event, data, id, retry.
event: update
data: {"value": 42}
data: This is a default message
Browsers automatically try to reconnect if the connection drops. The server can send a retry: 5000 field to control the delay.
Browsers (HTTP/1.1) limit concurrent connections (usually 6) per domain. Using HTTP/2 solves this (Multi-plexing).
Do:
: ping) to prevent proxies from killing idle connections.Last-Event-ID header to resume streams after incorrect.Don't:
| Error | Cause | Solution |
|---|---|---|
Buffered Response | Nginx/Proxy buffering the stream. | Disable proxy buffering (X-Accel-Buffering: no). |
Cors Error | Standard CORS rules apply. | Configure Access-Control headers. |