Class: Rapid::Server::StreamUpdater

Inherits:
Updater
  • Object
show all
Defined in:
lib/ury_rapid/server/updater.rb

Overview

An Updater that sends updates to a HTTP stream

Instance Method Summary collapse

Methods inherited from Updater

launch, #run

Constructor Details

#initialize(model, stream, privileges) ⇒ StreamUpdater

Returns a new instance of StreamUpdater


101
102
103
104
105
# File 'lib/ury_rapid/server/updater.rb', line 101

def initialize(model, stream, privileges)
  super(model)
  @privileges = privileges
  @stream = stream
end

Instance Method Details

#on_close(&block) ⇒ Object

Registers a block to call when the stream closes

The block receives no parameters.


128
129
130
131
# File 'lib/ury_rapid/server/updater.rb', line 128

def on_close(&block)
  @stream.callback(&block)
  @stream.errback(&block)
end

#on_messageObject

Dummy method for registering an on-message callback

HTTP streams are incapable of receiving messages, so this is a no-op.


112
113
114
# File 'lib/ury_rapid/server/updater.rb', line 112

def on_message
  # Can't receive messages from the stream
end

#requestObject

Dummy method for handling updater requests

HTTP streams are incapable of receiving requests, so this is a no-op.


119
120
121
# File 'lib/ury_rapid/server/updater.rb', line 119

def request
  # Can't take requests from the stream
end