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
 
@@ -37,9 +37,29 @@ class Live(cyclone.websocket.WebSocketHa
 
        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'))
 
            
 
@@ -129,6 +149,7 @@ if __name__ == "__main__":
 
    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,
light9/subserver/effects.coffee
Show inline comments
 
file renamed from light9/subserver/chases.coffee to light9/subserver/effects.coffee
 
@@ -25,14 +25,14 @@ 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
 
@@ -24,4 +24,4 @@ html
 
    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)