Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server-Sent Events using Telegraph #34

Closed
aplekhanov opened this issue Apr 25, 2018 · 1 comment
Closed

Server-Sent Events using Telegraph #34

aplekhanov opened this issue Apr 25, 2018 · 1 comment
Labels

Comments

@aplekhanov
Copy link

Hi! Is there the way to implement SSE on Telegraph server? Thanks!

@yvbeek
Copy link
Member

yvbeek commented Jul 14, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants