You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It should be possible to send comment events using play.api.libs.EventSource.Event (aka ServerSentEvents / SSE). These events start with a colon and can be used to keep the connection alive, e.g.:
: this is a keep alive message
data: some actual event with data
Yes, makes sense to support event comments, maybe as a new field in play.api.libs.EventSource.Event or even as its own type. For now, a possible workaround is to send events with event: heartbeat, for example:
valheartbeatEvent=Event(data = heartbeatData, name =Some("heartbeat"))
Ok.chunked(source.via(EventSource.flow).keepAlive(50.seconds, () => heartbeatEvent)).as(ContentTypes.EVENT_STREAM)
And on the client side have an event listener for heartbeat.
Play Version (2.7.0)
API (Scala)
Expected Behavior
It should be possible to send comment events using play.api.libs.EventSource.Event (aka ServerSentEvents / SSE). These events start with a colon and can be used to keep the connection alive, e.g.:
As described in https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Examples
This way you could keep a connection alive by e.g.:
Actual Behavior
The case class
play.api.libs.EventSource.Event
always formats the line with adata:
prefix. Hence pure comments / heartbeats can't be send.The text was updated successfully, but these errors were encountered: