Class: EStream::Evented
- Defined in:
- lib/e-core/instance/stream.rb
Instance Method Summary collapse
-
#data(data) ⇒ Object
(also: #<<)
sending data.
- #write(data) ⇒ Object
Methods inherited from Generic
#callback, #close, #closed?, defer, #each, #initialize, schedule
Constructor Details
This class inherits a constructor from EStream::Generic
Instance Method Details
#data(data) ⇒ Object Also known as: <<
sending data
142 143 144 145 146 |
# File 'lib/e-core/instance/stream.rb', line 142 def data data # - any single message should not contain \n except at the end. # - EventSource expects \n\n at the end of each single message. write "data: %s\n\n" % data.gsub(/\n|\r/, '') end |
#write(data) ⇒ Object
149 150 151 |
# File 'lib/e-core/instance/stream.rb', line 149 def write data @scheduler.schedule { @front.call(data.to_s) } end |