@rip-lang/server 1.1.10 → 1.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/server.rip +6 -0
package/package.json
CHANGED
package/server.rip
CHANGED
|
@@ -878,15 +878,21 @@ class Server
|
|
|
878
878
|
return new Response('not-found', { status: 404 }) unless group
|
|
879
879
|
encoder = new TextEncoder()
|
|
880
880
|
client = null
|
|
881
|
+
heartbeat = null
|
|
881
882
|
new Response new ReadableStream(
|
|
882
883
|
start: (controller) ->
|
|
883
884
|
send = (event) ->
|
|
884
885
|
try controller.enqueue encoder.encode("event: #{event}\n\n")
|
|
885
886
|
catch then null
|
|
887
|
+
ping = ->
|
|
888
|
+
try controller.enqueue encoder.encode(":\n\n")
|
|
889
|
+
catch then null
|
|
886
890
|
client = { send }
|
|
887
891
|
group.sseClients.add(client)
|
|
892
|
+
heartbeat = setInterval ping, 5000
|
|
888
893
|
send('connected')
|
|
889
894
|
cancel: ->
|
|
895
|
+
clearInterval(heartbeat) if heartbeat
|
|
890
896
|
group.sseClients.delete(client) if client
|
|
891
897
|
),
|
|
892
898
|
headers:
|