=sse: multi events

This commit is contained in:
Miki 2023-12-20 13:31:38 +01:00
parent e23ad2cbf2
commit d9a1837f3b
12 changed files with 15 additions and 15 deletions

BIN
sse/be/be

Binary file not shown.

View file

@ -92,7 +92,7 @@ func HeadersMiddleware() gin.HandlerFunc {
func (e *Event) Stream(c *gin.Context) {
client := &Client{
Ip: c.ClientIP(),
Ip: c.Request.RemoteAddr,
Chan: make(ClientChan),
Events: c.QueryArray("events"),
}

View file

@ -1 +1 @@
{"version":"1703074552121"}
{"version":"1703075413040"}

Binary file not shown.

Binary file not shown.

View file

@ -5,17 +5,17 @@
<link rel="icon" href="/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="modulepreload" href="/_app/immutable/entry/start.T-L7090x.js">
<link rel="modulepreload" href="/_app/immutable/entry/start.23JL8z_X.js">
<link rel="modulepreload" href="/_app/immutable/chunks/scheduler.k-kUyWhY.js">
<link rel="modulepreload" href="/_app/immutable/chunks/singletons.j1PGATaQ.js">
<link rel="modulepreload" href="/_app/immutable/entry/app.uCGb8Gwq.js">
<link rel="modulepreload" href="/_app/immutable/chunks/singletons.lz88bAPY.js">
<link rel="modulepreload" href="/_app/immutable/entry/app.kMziKss5.js">
<link rel="modulepreload" href="/_app/immutable/chunks/index.PctGSwCt.js">
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">
<script>
{
__sveltekit_gr3k9f = {
__sveltekit_1eon4i8 = {
base: "",
env: null
};
@ -23,8 +23,8 @@
const element = document.currentScript.parentElement;
Promise.all([
import("/_app/immutable/entry/start.T-L7090x.js"),
import("/_app/immutable/entry/app.uCGb8Gwq.js")
import("/_app/immutable/entry/start.23JL8z_X.js"),
import("/_app/immutable/entry/app.kMziKss5.js")
]).then(([kit, app]) => {
kit.start(app, element);
});

Binary file not shown.

Binary file not shown.

View file

@ -5,17 +5,17 @@
<link rel="icon" href="../favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="modulepreload" href="../_app/immutable/entry/start.T-L7090x.js">
<link rel="modulepreload" href="../_app/immutable/entry/start.23JL8z_X.js">
<link rel="modulepreload" href="../_app/immutable/chunks/scheduler.k-kUyWhY.js">
<link rel="modulepreload" href="../_app/immutable/chunks/singletons.j1PGATaQ.js">
<link rel="modulepreload" href="../_app/immutable/entry/app.uCGb8Gwq.js">
<link rel="modulepreload" href="../_app/immutable/chunks/singletons.lz88bAPY.js">
<link rel="modulepreload" href="../_app/immutable/entry/app.kMziKss5.js">
<link rel="modulepreload" href="../_app/immutable/chunks/index.PctGSwCt.js">
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">
<script>
{
__sveltekit_gr3k9f = {
__sveltekit_1eon4i8 = {
base: new URL("..", location).pathname.slice(0, -1),
env: null
};
@ -23,8 +23,8 @@
const element = document.currentScript.parentElement;
Promise.all([
import("../_app/immutable/entry/start.T-L7090x.js"),
import("../_app/immutable/entry/app.uCGb8Gwq.js")
import("../_app/immutable/entry/start.23JL8z_X.js"),
import("../_app/immutable/entry/app.kMziKss5.js")
]).then(([kit, app]) => {
kit.start(app, element);
});

Binary file not shown.

Binary file not shown.

View file

@ -13,7 +13,7 @@
}
function SSEMsg() {
const sse = new EventSource(`/api/sse?event=ping&event=pong`);
const sse = new EventSource(`/api/sse?events=ping,pong`);
console.log('subscribe ping pong');
sse.onopen = () => {