lib/template/wsserver.rb in browser_app_base-0.0.2 vs lib/template/wsserver.rb in browser_app_base-0.0.3

- old
+ new

@@ -1,7 +1,6 @@ -require "./server_app" -$app = AppMain.new +require "./server_app_base" class WsServer < Sinatra::Base $ws_list = [] get "" do if !request.websocket? @@ -13,19 +12,26 @@ $ws_list << ws end ws.onmessage do |msg| puts msg if msg =~ /^exec:/ - fname = msg.gsub(/^exec:/, "") + argv = msg.gsub(/^exec:/, "") Thread.new { - $app.start fname do |out| + $app.start(argv.split(",")) do |out| ws.send(out) end } end if msg =~ /^stop/ $app.stop end + if msg =~ /^suspend/ + $app.suspend + end + if msg =~ /^resume/ + $app.resume + end + if msg == "exit" unless ENV["OCRA"] == "true" halt #exit end