lib/template/wsserver.rb in browser_app_base-0.0.9 vs lib/template/wsserver.rb in browser_app_base-0.1.0
- old
+ new
@@ -49,15 +49,15 @@
Thread.kill $ws_exit_thread
end
end
ws.onmessage do |msg|
puts msg
+ json = JSON.parse(File.read("config/setting.json"))
+ json_config = config_json_hash(json)
+ $app.set_config(json_config)
if msg =~ /^exec:/
if exec_thread == nil
- json = JSON.parse(File.read("config/setting.json"))
- json_config = config_json_hash(json)
- $app.set_config(json_config)
argv = msg.gsub(/^exec:/, "")
exec_thread = Thread.new {
begin
$app.start(argv.split(",")) do |out|
ws_send(out)
@@ -78,9 +78,11 @@
ws_send("app_end:error")
end
end
if msg =~ /^stop/
if exec_thread
+ Thread.kill exec_thread
+ ws_send("app_end:stop")
$app.stop
end
end
if msg =~ /^suspend/
if exec_thread