app/controllers/extface/jobs_controller.rb in extface-0.3.0c vs app/controllers/extface/jobs_controller.rb in extface-0.3.0
- old
+ new
@@ -12,17 +12,15 @@
elsif @job.failed?
response.stream.write("data: Job #{@job.id} failed!\n\n")
else
#redis = Redis.new
response.stream.write("data: Job #{@job.id} waiting for device connection...\n\n")
- Timeout.timeout(Extface.device_timeout) do #never stay too long, TODO add SSE option to reconnect
- Extface.redis_block do |r|
- r.subscribe(@job.id) do |on|
- on.message do |event, data|
- p "@@@@ #{event}: #{data}\n\n"
- response.stream.write("data: #{data}\n\n") unless data == 'OK'
- r.unsubscribe if data == "Job #{@job.id} completed!" || data == "Job #{@job.id} failed!" #FIXME stupid
- end
+ Extface.redis_block do |r|
+ r.subscribe(@job.id) do |on|
+ on.message do |event, data|
+ #p "data: #{data}\n\n"
+ response.stream.write("data: #{data}\n\n") unless data == 'OK'
+ r.unsubscribe if data == "Job #{@job.id} completed!" || data == "Job #{@job.id} failed!"
end
end
end
end
ensure