Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated stream.rb.

  • Loading branch information...
commit 708ac1dbfb71f146ba5b1e0bafa36a1fe098aef7 1 parent d1a46a9
@tekacs tekacs authored
Showing with 7 additions and 3 deletions.
  1. +7 −3 stream.rb
View
10 stream.rb
@@ -9,8 +9,11 @@ def on_close(env)
def response(env)
- keepalive = EM.add_periodic_timer(1) do
- env.stream_send(".\n")
+ # This timer keeps the connection alive later in the stream when
+ # the number generation slows down sufficiently for > 30s response time.
+ # Yes, the timer is something like 55s but I like 30s, okay? ;)
+ keepalive = EM.add_periodic_timer(29) do
+ env.stream_send("Heartbeat.\n")
end
EM.defer do
@@ -23,7 +26,8 @@ def response(env)
end
end
- # EM.add_timer(10) do
+ # The below cuts off the connection at some point if this is desired.
+ # EM.add_timer(30) do
# keepalive.cancel
#
# env.stream_send("End of stream.")
Please sign in to comment.
Something went wrong with that request. Please try again.