forked from 0x2620/pandora
ignore messages that can not be serialized
This commit is contained in:
parent
af86445b2e
commit
47a3a24a7d
1 changed files with 10 additions and 2 deletions
|
@ -62,14 +62,22 @@ class Handler(WebSocketHandler):
|
|||
#logger.debug('got message %s', message)
|
||||
|
||||
def post(self, event, data):
|
||||
try:
|
||||
message = json.dumps([event, data])
|
||||
except:
|
||||
logger.debug('failed to serialize data %s %s', event, data)
|
||||
return
|
||||
main = IOLoop.instance()
|
||||
main.add_callback(lambda: self.write_message(message))
|
||||
|
||||
def trigger_event(event, data):
|
||||
logger.debug('trigger event %s %s to %s clients', event, data, len(sockets))
|
||||
main = IOLoop.instance()
|
||||
try:
|
||||
message = json.dumps([event, data])
|
||||
except:
|
||||
logger.debug('faild to serialise data')
|
||||
return
|
||||
for ws in sockets:
|
||||
try:
|
||||
main.add_callback(lambda: ws.write_message(message))
|
||||
|
|
Loading…
Reference in a new issue