Changeset - 448fe9f81501
[Not reviewed]
default
2 1 2
Drew Perttula - 11 years ago 2014-06-09 07:30:23
drewp@bigasterisk.com
start to convert subserver to offer the new effects
Ignore-this: 8dcbd993db2e451d80da200cd2cfbc81
3 files changed with 28 insertions and 7 deletions:
0 comments (0 inline, 0 general)
bin/subserver
Show inline comments
 
@@ -34,15 +34,35 @@ class Live(cyclone.websocket.WebSocketHa
 
        liveClients.remove(self)
 

	
 
    def messageReceived(self, message):
 
        log.info("got message %s" % message)
 
        self.sendMessage(message)
 
        
 
class EffectsUpdates(cyclone.websocket.WebSocketHandler):
 
    def connectionMade(self, *args, **kwargs):
 
        self.connected = True
 
        self.settings.graph.addHandler(self.onGraphChange)
 
        
 
    def connectionLost(self, reason):
 
        self.connected = False
 
        
 
    def onGraphChange(self):
 
        if not self.connected:
 
            return
 
        graph = self.settings.graph
 
        classes = []
 
        for e in graph.subjects(RDF.type, L9['EffectClass']):
 
            classes.append({'uri': e,
 
                            'label': graph.label(e),
 
                            'code': graph.value(e, L9['code'])})
 
        print "sendMessage", classes
 
        self.sendMessage({'classes': classes})
 

	
 
class Static(PrettyErrorHandler, cyclone.web.StaticFileHandler):
 
    def get(self, path, *args, **kw):
 
        if path in ['', 'chases']:
 
        if path in ['', 'effects']:
 
            return self.respondStaticJade("light9/subserver/%s.jade" %
 
                                          (path or 'index'))
 
            
 
        if path.endswith(".js"):
 
            return self.responseStaticCoffee(
 
                'light9/subserver/%s' %
 
@@ -126,12 +146,13 @@ if __name__ == "__main__":
 
    graph.addHandler(updateSubs)
 
    
 
    
 
    port = 8052
 
    reactor.listenTCP(port, cyclone.web.Application(handlers=[
 
        (r'/live', Live),
 
        (r'/effectsUpdates', EffectsUpdates),
 
        (r'/snapshot', Snapshot),
 
        (r'/static/(.*)', cyclone.web.StaticFileHandler, {'path': 'static/'}),
 
        (r'/(.*)', Static,
 
         {"path" : "light9/subserver",
 
          "default_filename" : "index.jade"}),
 
        ], debug=True, graph=graph, onNewClient=onNewClient))
light9/subserver/effects.coffee
Show inline comments
 
file renamed from light9/subserver/chases.coffee to light9/subserver/effects.coffee
 
@@ -22,17 +22,17 @@ class Model
 
    ]
 
  
 

	
 

	
 
model = new Model()
 

	
 

	
 
reconnectingWebSocket "ws://localhost:8052/effectsUpdates", (msg) ->
 
  model.chases(msg.chases) if msg.chases?
 

	
 
# this sort of works to stop clicks in <input> from following the
 
# submaster hyperlink, but it may make certain clicks act wrong
 
$('a').live('click', (ev) ->
 
$(document).on('click', 'a', (ev) ->
 
  return false if ev.target.tagName == 'INPUT'
 
)
 

	
 
reconnectingWebSocket "ws://localhost:8052/live", (msg) ->
 
  model.chases(msg.chases) if msg.chases?
 

	
 

	
 
ko.applyBindings(model)
 
\ No newline at end of file
light9/subserver/effects.jade
Show inline comments
 
file renamed from light9/subserver/chases.jade to light9/subserver/effects.jade
 
@@ -21,7 +21,7 @@ html
 

	
 
    #status
 
      
 
    script(src="static/jquery-2.1.1.min.js")
 
    script(src="static/knockout-3.1.0.js")
 
    script(src="static/websocket.js")
 
    script(src="chases.js")
 
\ No newline at end of file
 
    script(src="effects.js")
 
\ No newline at end of file
0 comments (0 inline, 0 general)