Server-Sent Events using Telegraph
aplekhanov opened this issue · comments
Hi! Is there the way to implement SSE on Telegraph server? Thanks!
In order to make that work, the server would have to keep an HTTP connection open and allow the developer to write data back to the client asynchronously.
You could probably tap into the Server's connection(_ httpConnection: HTTPConnection, handleIncomingRequest request: HTTPRequest, error: Error?)
function and keep your own reference to the HTTPConnection
.
On the HTTPConnection
you can call send(response: HTTPResponse)
to send responses to the client over the connection. Perhaps you can test this out by using a DispatchTimer
(helper in Telegraph) and send a response every few seconds.