class ActionController::SSETest::SSETestController

Public Instance Methods

basic_sse() click to toggle source
# File actionpack/test/controller/live_stream_test.rb, line 13
def basic_sse
  response.headers["Content-Type"] = "text/event-stream"
  sse = SSE.new(response.stream)
  sse.write("{\"name\":\"John\"}")
  sse.write(name: "Ryan")
ensure
  sse.close
end
sse_with_event() click to toggle source
# File actionpack/test/controller/live_stream_test.rb, line 22
def sse_with_event
  sse = SSE.new(response.stream, event: "send-name")
  sse.write("{\"name\":\"John\"}")
  sse.write(name: "Ryan")
ensure
  sse.close
end
sse_with_id() click to toggle source
# File actionpack/test/controller/live_stream_test.rb, line 38
def sse_with_id
  sse = SSE.new(response.stream)
  sse.write("{\"name\":\"John\"}", id: 1)
  sse.write({ name: "Ryan" }, { id: 2 })
ensure
  sse.close
end
sse_with_multiple_line_message() click to toggle source
# File actionpack/test/controller/live_stream_test.rb, line 46
def sse_with_multiple_line_message
  sse = SSE.new(response.stream)
  sse.write("first line.\nsecond line.")
ensure
  sse.close
end
sse_with_retry() click to toggle source
# File actionpack/test/controller/live_stream_test.rb, line 30
def sse_with_retry
  sse = SSE.new(response.stream, retry: 1000)
  sse.write("{\"name\":\"John\"}")
  sse.write({ name: "Ryan" }, { retry: 1500 })
ensure
  sse.close
end