Selaa lähdekoodia

minor server-sent events fixes (#12945)

* Send output on the server-sent events stream immediately so the client sees that it was successfully opened even if it doesn't have any messages.

Fix transparent SSE streaming for the public:local and hashtag:local stream types.

* Tell caches to never store server-sent events.
master^2
Ben Lubar 4 vuotta sitten
committed by Eugen Rochko
vanhempi
commit
0dfba0884e
2 muutettua tiedostoa jossa 4 lisäystä ja 0 poistoa
  1. +1
    -0
      app/javascript/mastodon/stream.js
  2. +3
    -0
      streaming/index.js

+ 1
- 0
app/javascript/mastodon/stream.js Näytä tiedosto

@@ -92,6 +92,7 @@ export default function getStream(streamingAPIBaseURL, accessToken, stream, { co
return ws;
}

stream = stream.replace(/:/g, '/');
params.push(`access_token=${accessToken}`);
const es = new EventSource(`${streamingAPIBaseURL}/api/v1/streaming/${stream}?${params.join('&')}`);



+ 3
- 0
streaming/index.js Näytä tiedosto

@@ -436,8 +436,11 @@ const startWorker = (workerId) => {
const accountId = req.accountId || req.remoteAddress;

res.setHeader('Content-Type', 'text/event-stream');
res.setHeader('Cache-Control', 'no-store');
res.setHeader('Transfer-Encoding', 'chunked');

res.write(':)\n');

const heartbeat = setInterval(() => res.write(':thump\n'), 15000);

req.on('close', () => {


Ladataan…
Peruuta
Tallenna