コード例 #1
0
    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()))
コード例 #2
0
ファイル: __init__.py プロジェクト: ppaez/pyvore
    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()))