Class: Angelo::Base::EventSource

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/angelo/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(socket) ⇒ EventSource

Returns a new instance of EventSource.



319
320
321
# File 'lib/angelo/base.rb', line 319

def initialize socket
  @socket = socket
end

Instance Attribute Details

#socketObject (readonly)

Returns the value of attribute socket.



317
318
319
# File 'lib/angelo/base.rb', line 317

def socket
  @socket
end

Instance Method Details

#event(name, data = nil) ⇒ Object



323
324
325
# File 'lib/angelo/base.rb', line 323

def event name, data = nil
  @socket.write Base.sse_event(name, data)
end

#message(data) ⇒ Object



327
328
329
# File 'lib/angelo/base.rb', line 327

def message data
  @socket.write Base.sse_message(data)
end