Module: R4S
- Defined in:
- lib/r4s.rb
Defined Under Namespace
Classes: SSE
Constant Summary collapse
- SSES =
ThreadSafe::Hash.new
Class Method Summary collapse
-
.add_stream(response, session, key = "none") ⇒ Object
The session_id is used to identify users who already have a connection The key is used to group “identical” sse-streams so you can push data to a group of streams.
- .push_data(key, data, options = {}) ⇒ Object
Class Method Details
.add_stream(response, session, key = "none") ⇒ Object
The session_id is used to identify users who already have a connection The key is used to group “identical” sse-streams so you can push data to a group of streams
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/r4s.rb', line 8 def self.add_stream(response,session,key="none") id = session["session_id"] R4S::SSES[key] = ThreadSafe::Hash.new unless R4S::SSES.keys.include?(key) if R4S::SSES[key].keys.include?(id) sse = R4S::SSES[key][id] sse.close end sse = R4S::SSE.new(response,key,id) R4S::SSES[key][id] = sse return sse end |