changeset 1217:e703b3434dbd

websocket and web cleanup Ignore-this: ac6bd0444bc03ee79ce71c4aa7740bc0
author Drew Perttula <drewp@bigasterisk.com>
date Mon, 08 Jun 2015 02:08:25 +0000
parents 896979e6f352
children ab72450ef4b1
files bin/effecteval bin/homepageConfig bin/subserver light9/effecteval/effect.coffee light9/effecteval/effect.html light9/effecteval/index.coffee light9/effecteval/index.html light9/networking.py light9/rdfdb/web/graphView.xhtml light9/rdfdb/web/index.xhtml light9/rdfdb/web/syncedgraph.js light9/subcomposer/index.html light9/subcomposer/subcomposerweb.py light9/subserver/effects.coffee light9/subserver/effects.jade light9/subserver/gui.coffee light9/subserver/index.jade light9/web/websocket.js show/dance2014/networking.n3
diffstat 19 files changed, 67 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/bin/effecteval	Mon Jun 08 00:38:49 2015 +0000
+++ b/bin/effecteval	Mon Jun 08 02:08:25 2015 +0000
@@ -24,6 +24,7 @@
 
 class EffectEdit(PrettyErrorHandler, cyclone.web.RequestHandler):
     def get(self):
+        self.set_header('Content-Type', 'text/html')        
         self.write(open("light9/effecteval/effect.html").read())
     def delete(self):
         graph = self.settings.graph
--- a/bin/homepageConfig	Mon Jun 08 00:38:49 2015 +0000
+++ b/bin/homepageConfig	Mon Jun 08 02:08:25 2015 +0000
@@ -18,7 +18,18 @@
                 continue
             path = current.value(role, L9['urlPath'])
             server = server.rstrip('/')
-            print "location /%(path)s { proxy_pass %(server)s; rewrite /[^/]+/(.*) /$1 break; }" % vars()
+            print """
+            location /%(path)s {
+
+              # for websocket
+              proxy_http_version 1.1;
+              proxy_set_header Upgrade $http_upgrade;
+              proxy_set_header Connection "upgrade";
+              proxy_set_header Host $host;
+
+              proxy_pass %(server)s;
+              rewrite /[^/]+/(.*) /$1 break;
+            }""" % vars()
 
     reactor.stop()
 
--- a/bin/subserver	Mon Jun 08 00:38:49 2015 +0000
+++ b/bin/subserver	Mon Jun 08 02:08:25 2015 +0000
@@ -115,7 +115,7 @@
 
     log.setLevel(logging.DEBUG if options.verbose else logging.INFO)
 
-    graph = SyncedGraph(networking.rdfdb.url, "subserver")
+    graph = SyncedGraph(networking.rdfdb.url, "subServer")
 
     d = {}
     def updateSubs():
@@ -146,7 +146,7 @@
     graph.addHandler(updateSubs)
     
     
-    port = 8052
+    port = networking.subServer.port
     reactor.listenTCP(port, cyclone.web.Application(handlers=[
         (r'/live', Live),
         (r'/effectsUpdates', EffectsUpdates),
--- a/light9/effecteval/effect.coffee	Mon Jun 08 00:38:49 2015 +0000
+++ b/light9/effecteval/effect.coffee	Mon Jun 08 02:08:25 2015 +0000
@@ -4,7 +4,7 @@
     uri: ko.observable(qs.value('uri'))
     codeLines: ko.observableArray([])
   
-socket = reconnectingWebSocket "ws://localhost:8070/effectUpdates" + window.location.search, (msg) ->
+socket = reconnectingWebSocket "../effectUpdates" + window.location.search, (msg) ->
   console.log('effectData ' + JSON.stringify(msg))
   model.toSave.codeLines(msg.codeLines.map((x) -> {text: ko.observable(x)})) if msg.codeLines?
 
--- a/light9/effecteval/effect.html	Mon Jun 08 00:38:49 2015 +0000
+++ b/light9/effecteval/effect.html	Mon Jun 08 02:08:25 2015 +0000
@@ -7,6 +7,8 @@
 
   </head>
   <body>
+    <div id="status">starting...</div>
+
     <a href="./">Effects</a> / <a class="effect" data-bind="attr: {href: toSave.uri}, text: toSave.uri"></a>
 
     <div data-bind="foreach: toSave.codeLines">
--- a/light9/effecteval/index.coffee	Mon Jun 08 00:38:49 2015 +0000
+++ b/light9/effecteval/index.coffee	Mon Jun 08 02:08:25 2015 +0000
@@ -21,7 +21,7 @@
     url: 'effect?' + $.param({uri: uri})
   console.log("del", uri)
   
-reconnectingWebSocket "ws://localhost:8070/songEffectsUpdates", (msg) ->
+reconnectingWebSocket "songEffectsUpdates", (msg) ->
   for s in msg.songs
     for e in s.effects
       do (e) ->
--- a/light9/effecteval/index.html	Mon Jun 08 00:38:49 2015 +0000
+++ b/light9/effecteval/index.html	Mon Jun 08 02:08:25 2015 +0000
@@ -6,6 +6,7 @@
     <link rel="stylesheet" href="/style.css">
   </head>
   <body>
+    <div id="status">starting...</div>
     <div><a href="stats">/stats</a></div>
     <h1>Effect instances</h1>
     <div><a href=".">View all songs</a></div>
--- a/light9/networking.py	Mon Jun 08 00:38:49 2015 +0000
+++ b/light9/networking.py	Mon Jun 08 02:08:25 2015 +0000
@@ -35,15 +35,16 @@
     def path(self, more):
         return self.url + str(more)
 
+curveCalc = ServiceAddress(L9['curveCalc'])
 dmxServer = ServiceAddress(L9['dmxServer'])
-oscDmxServer = ServiceAddress(L9['oscDmxServer'])
-musicPlayer = ServiceAddress(L9['musicPlayer'])
+effectEval = ServiceAddress(L9['effectEval'])
 keyboardComposer = ServiceAddress(L9['keyboardComposer'])
-curveCalc = ServiceAddress(L9['curveCalc'])
-vidref = ServiceAddress(L9['vidref'])
-effectEval = ServiceAddress(L9['effectEval'])
+musicPlayer = ServiceAddress(L9['musicPlayer'])
+oscDmxServer = ServiceAddress(L9['oscDmxServer'])
 picamserve = ServiceAddress(L9['picamserve'])
 rdfdb = ServiceAddress(L9['rdfdb'])
 subComposer = ServiceAddress(L9['subComposer'])
+subServer = ServiceAddress(L9['subServer'])
+vidref = ServiceAddress(L9['vidref'])
 
 patchReceiverUpdateHost = ServiceAddress(L9['patchReceiverUpdateHost'])
--- a/light9/rdfdb/web/graphView.xhtml	Mon Jun 08 00:38:49 2015 +0000
+++ b/light9/rdfdb/web/graphView.xhtml	Mon Jun 08 02:08:25 2015 +0000
@@ -13,8 +13,8 @@
         graph all the time
     -->
 
-    <p>status: <span id="status">starting...</span></p>
-
+    <div id="status">starting...</div>
+    
     <fieldset>
       <legend>Messages</legend>
       <div id="out"></div>
--- a/light9/rdfdb/web/index.xhtml	Mon Jun 08 00:38:49 2015 +0000
+++ b/light9/rdfdb/web/index.xhtml	Mon Jun 08 02:08:25 2015 +0000
@@ -8,7 +8,7 @@
   </head>
   <body>
     <h1>rdfdb</h1>
-    <p>status: <span id="status">starting...</span></p>
+    <div id="status">starting...</div>
     
     <section>
       <h2>Edits</h2>
@@ -52,7 +52,7 @@
 
               $('#out').append($('<div>').text(JSON.stringify(d)));
           }
-          reconnectingWebSocket("ws://localhost:8051/live", onMessage);
+          reconnectingWebSocket("live", onMessage);
       });
       // ]]>
     </script>
--- a/light9/rdfdb/web/syncedgraph.js	Mon Jun 08 00:38:49 2015 +0000
+++ b/light9/rdfdb/web/syncedgraph.js	Mon Jun 08 02:08:25 2015 +0000
@@ -23,5 +23,5 @@
         $('#out').append($('<div>').text(JSON.stringify(d)));
     }
     
-    reconnectingWebSocket("ws://localhost:8051/liveSyncedGraph", onMessage);
+    reconnectingWebSocket("liveSyncedGraph", onMessage);
 }
--- a/light9/subcomposer/index.html	Mon Jun 08 00:38:49 2015 +0000
+++ b/light9/subcomposer/index.html	Mon Jun 08 02:08:25 2015 +0000
@@ -44,7 +44,7 @@
     <button data-chan="http://light9.bigasterisk.com/theater/piedmont/channel/f11-blue">f11-blue</button>
     <button data-chan="http://light9.bigasterisk.com/theater/piedmont/channel/f12-purp">f12-purp</button>
 
-    <script src="static/jquery-2.1.1.min.js"></script>
+    <script src="/lib/jquery-2.1.1.min.js"></script>
     <script>
       $(document).on("click", "button", function (ev) {
           var chan = ev.target.getAttribute('data-chan');
--- a/light9/subcomposer/subcomposerweb.py	Mon Jun 08 00:38:49 2015 +0000
+++ b/light9/subcomposer/subcomposerweb.py	Mon Jun 08 02:08:25 2015 +0000
@@ -11,7 +11,6 @@
     app = cyclone.web.Application(handlers=[
         (r'/()', SFH,
          {'path': 'light9/subcomposer', 'default_filename': 'index.html'}),
-        (r'/static/(.*)', SFH, {'path': 'static/'}),
         (r'/toggle', Toggle),
     ], debug=True, graph=graph, currentSub=currentSub)
     reactor.listenTCP(networking.subComposer.port, app)
--- a/light9/subserver/effects.coffee	Mon Jun 08 00:38:49 2015 +0000
+++ b/light9/subserver/effects.coffee	Mon Jun 08 02:08:25 2015 +0000
@@ -33,7 +33,7 @@
     data: {drop: e.uri}
   })
 
-reconnectingWebSocket "ws://localhost:8052/effectsUpdates", (msg) ->
+reconnectingWebSocket "../effectsUpdates", (msg) ->
   model.chases(msg.chases) if msg.chases?
   model.classes(msg.classes) if msg.classes?
 
--- a/light9/subserver/effects.jade	Mon Jun 08 00:38:49 2015 +0000
+++ b/light9/subserver/effects.jade	Mon Jun 08 02:08:25 2015 +0000
@@ -4,7 +4,10 @@
     title effects
     link(rel='stylesheet', href='/style.css')
   body
+    #status starting...
     h1 Effects
+    p: a(href='.') Go to Submasters
+
 
     div(data-bind="foreach: moreExprs")
       div.resource.chase
--- a/light9/subserver/gui.coffee	Mon Jun 08 00:38:49 2015 +0000
+++ b/light9/subserver/gui.coffee	Mon Jun 08 02:08:25 2015 +0000
@@ -18,7 +18,7 @@
   return false if ev.target.tagName == 'INPUT'
 )
 
-reconnectingWebSocket "ws://localhost:8052/live", (msg) ->
+reconnectingWebSocket "live", (msg) ->
   model.subs(msg.subs) if msg.subs?
 
 
--- a/light9/subserver/index.jade	Mon Jun 08 00:38:49 2015 +0000
+++ b/light9/subserver/index.jade	Mon Jun 08 02:08:25 2015 +0000
@@ -4,7 +4,9 @@
     title subs
     link(rel='stylesheet', href='/style.css')
   body
+    #status starting...
     h1 Submasters
+    p: a(href='effects') Go to Effects
 
     div
       input(type='checkbox', data-bind='checked: showLocal', id='showLocal')
--- a/light9/web/websocket.js	Mon Jun 08 00:38:49 2015 +0000
+++ b/light9/web/websocket.js	Mon Jun 08 02:08:25 2015 +0000
@@ -1,7 +1,17 @@
+/*
+  url is now relative to the window location
+*/
 function reconnectingWebSocket(url, onMessage) {
     var pong = 0;
+    
+    var fullUrl = (
+        "ws://"
+            + window.location.host
+            + window.location.pathname
+            + (window.location.pathname.match(/\/$/) ? "" : "/")
+            + url);
     function connect() {
-        var ws = new WebSocket(url);
+        var ws = new WebSocket(fullUrl);
         
         ws.onopen = function() {   $("#status").text("connected"); };
         ws.onerror = function(e) { $("#status").text("error: "+e); };
@@ -17,4 +27,4 @@
         };
     }
     connect();
-}
\ No newline at end of file
+}
--- a/show/dance2014/networking.n3	Mon Jun 08 00:38:49 2015 +0000
+++ b/show/dance2014/networking.n3	Mon Jun 08 02:08:25 2015 +0000
@@ -5,24 +5,25 @@
 show:dance2014 :networking sh:netHome .
 sh:netHome
   :patchReceiverUpdateHost "localhost";
+  :curveCalc        <http://dash:8060/>;
+  :dmxServer        <http://dash:8030/>;
+  :effectEval       <http://dash:8070/>;
+  :keyboardComposer <http://dash:8050/>;
+  :musicPlayer      <http://dash:8040/>;
+  :oscDmxServer     <udp://dash:9050/>;
+  :picamserve       <http://10.2.0.3:8001/>;
   :rdfdb            <http://localhost:8051/>;
-  :effectEval       <http://plus:8070/>;
-  :musicPlayer      <http://plus:8040/>;
-  :dmxServer        <http://plus:8030/>;
-  :oscDmxServer     <udp://plus:9050/>;
-  :curveCalc        <http://plus:8060/>;
-  :keyboardComposer <http://plus:8050/>;
-  :subComposer <http://plus:8054/>;
-  :picamserve       <http://10.2.0.3:8001/>;
+  :subComposer      <http://dash:8055/>;
+  :subServer        <http://dash:8052/>;
   :vidref           <http://dash:8053/> .
 
-:rdfdb            :urlPath "rdfdb" .
-:effectEval       :urlPath "effectEval" .
-:musicPlayer      :urlPath "ascoltami" .
+:curveCalc        :urlPath "curveCalc" .
 :dmxServer        :urlPath "dmxServer" .
-:oscDmxServer     :urlPath "oscDmxServer" .
-:curveCalc        :urlPath "curveCalc" .
+:effectEval       :urlPath "effectEval" .
 :keyboardComposer :urlPath "keyboardComposer" .
-:subComposer      :urlPath "subComposer" .
+:musicPlayer      :urlPath "ascoltami" .
 :picamserve       :urlPath "picamserve" .
-:vidref           :urlPath "vidref" .
+:rdfdb            :urlPath "rdfdb" .
+:subComposer      :urlPath "subComposer" .
+:subServer        :urlPath "subServer" .
+:vidref           :urlPath "vidref" .
\ No newline at end of file