This is an automated email from the ASF dual-hosted git repository.

rubys pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/whimsy.git

The following commit(s) were added to refs/heads/master by this push:
       new  a233474   remote restart
a233474 is described below

commit a2334749f3720584f247d7fa8f5f2e037e672a70
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Sun Oct 16 11:13:32 2016 -0400

    remote restart
---
 www/board/agenda/daemon/wsc.rb | 23 ++++++++++++++++++++++-
 www/board/agenda/daemon/wss.rb |  2 +-
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/www/board/agenda/daemon/wsc.rb b/www/board/agenda/daemon/wsc.rb
index ac00bb0..0fdc1ce 100644
--- a/www/board/agenda/daemon/wsc.rb
+++ b/www/board/agenda/daemon/wsc.rb
@@ -3,6 +3,9 @@ require 'bundler/setup'
 require 'websocket-client-simple'
 require 'optparse'
 require 'ostruct'
+require 'etc'
+
+require_relative './session'
 
 # monkey patch for https://github.com/shokai/websocket-client-simple/issues/24
 class WebSocket::Client::Simple::Client
@@ -19,6 +22,8 @@ options = OpenStruct.new
 options.host = 'localhost'
 options.port = 34234
 options.protocol = 'ws'
+options.user = Etc.getlogin
+options.restart = false
 
 opt_parser = OptionParser.new do |opts|
   opts.banner = "Usage: #{File.basename(__FILE__)} [options]"
@@ -34,6 +39,14 @@ opt_parser = OptionParser.new do |opts|
   opts.on "--secure", 'Use secure web sockets (wss)' do
     options.protocol = 'wss'
   end
+
+  opts.on "--user USER", 'User to log in as' do |user|
+    options.user = user
+  end
+
+  opts.on "--restart", 'restart WebSocket daemon process' do
+    options.restart = true
+  end
 end
 
 opt_parser.parse!(ARGV)
@@ -50,7 +63,15 @@ ws.on :message do |msg|
 end
 
 ws.on :open do
-  ws.send 'hello!!!'
+  Dir["#{Session::WORKDIR}/*"].find do |file| 
+    if File.read(file) == options.user
+      if options.restart
+        ws.send "session: #{File.basename(file)}\nrestart: true\n\n"
+      else
+        ws.send "session: #{File.basename(file)}\n\n"
+      end
+    end
+  end
 end
 
 ws.on :close do |e|
diff --git a/www/board/agenda/daemon/wss.rb b/www/board/agenda/daemon/wss.rb
index e201d32..8c07df0 100755
--- a/www/board/agenda/daemon/wss.rb
+++ b/www/board/agenda/daemon/wss.rb
@@ -123,7 +123,7 @@ EM.run do
 
     ws.onmessage do |msg|
       # extract headers
-      headers = msg.slice!(/\A(\w+:\s*.*\r?\n)\s*(\n|\Z)/).to_s
+      headers = msg.slice!(/\A(\w+:\s*.*\r?\n)+\s*(\n|\Z)/).to_s
       headers = YAML.safe_load(headers) || {} rescue {}
 
       if headers['session']

-- 
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <commits@whimsical.apache.org>'].

Reply via email to