def on_chat(self, msg_id, msg): """Called by client-side: chat.emit("chat", {"foo": "bar"});""" r = redis.Redis() chat_line = msg chat = Chat(chat_line=chat_line, user_pk=self.request.user.pk, session_pk=int(msg_id)) DBSession.add(chat) DBSession.commit() # only publish to the channel the message came from r.publish('chat:' + msg_id, dumps(chat.serialize()))
def on_chat(self, msg_id, msg): """Called by client-side: chat.emit("chat", {"foo": "bar"});""" r = redis.Redis() chat_line = msg chat = Chat(chat_line=chat_line, user_pk=self.request.user.pk, session_pk=int(msg_id) ) DBSession.add(chat) DBSession.commit() # only publish to the channel the message came from r.publish('chat:' + msg_id, dumps(chat.serialize()))