Mercurial > code > home > repos > light9
diff bin/subserver @ 1104:448fe9f81501
start to convert subserver to offer the new effects
Ignore-this: 8dcbd993db2e451d80da200cd2cfbc81
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Mon, 09 Jun 2014 07:30:23 +0000 |
parents | 473db8bebb8f |
children | a38955ba6f40 |
line wrap: on
line diff
--- a/bin/subserver Mon Jun 09 07:10:39 2014 +0000 +++ b/bin/subserver Mon Jun 09 07:30:23 2014 +0000 @@ -37,9 +37,29 @@ 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 @@ 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,