Class: RhoDevelopment::ResponseFromDevice

Inherits:
WEBrick::HTTPServlet::AbstractServlet
  • Object
show all
Defined in:
lib/build/development/web_server.rb

Instance Method Summary collapse

Constructor Details

#initialize(server, instance) ⇒ ResponseFromDevice

Returns a new instance of ResponseFromDevice.



174
175
176
177
# File 'lib/build/development/web_server.rb', line 174

def initialize server, instance
  super server
  @instance = instance
end

Instance Method Details

#do_POST(request, response) ⇒ Object



179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/build/development/web_server.rb', line 179

def do_POST request, response
  subscriber = Configuration::subscriber_by_ip(request.query['ip'])
  if request.query['status'] == 'need_full_update'
    puts "#{subscriber} is requesting full update bundle".info
    filename = RhoDevelopment::Configuration::next_filename_for_downloading()
    WebServer::dispatch_task(SubscriberFullBundleUpdateBuildingTask.new(subscriber, filename))
    WebServer::dispatch_task(SubscriberFullUpdateNotifyingTask.new(subscriber, filename))
  end
  if request.query['status'] == 'ok'
    puts "#{subscriber} applied update bundle successfully".info
  end
  if request.query['status'] == 'error'
    puts "#{subscriber} got an error while updating bundle: #{request.query['message']}".info
  end

  response.status = 200
  response.body = ''
end