Beispiel #1
0
    def on_chat(self, msg):
        r = redis.Redis()

        # store the data in the database using sqlalchemy
        chat = Chat(chat_line=msg)
        DBSession.add(chat)
        DBSession.commit()

        # we got a new chat event from the client, send it out to
        # all the listeners
        r.publish('chat', dumps(chat.serialize()))
Beispiel #2
0
    def on_chat(self, msg):
        r = redis.Redis()

        # store the data in the database using sqlalchemy
        chat = Chat(chat_line = msg)
        DBSession.add(chat)
        DBSession.commit()

        # we got a new chat event from the client, send it out to
        # all the listeners
        r.publish('chat', dumps(chat.serialize()))
Beispiel #3
0
def socketio_service(request):
    r = redis.Redis()

    socketio = request.environ["socketio"]

    gevent.spawn(listener, socketio)

    while True:
        message = socketio.receive()

        if message:
            if message["type"] == "event":
                if message['name'] == "chat":
                    # store the data in the database using sqlalchemy
                    chat_line = ''.join(message['args'])
                    chat = Chat(chat_line = chat_line)
                    DBSession.add(chat)
                    DBSession.commit()

                    # we got a new chat event from the client, send it out to
                    # all the listeners
                    r.publish('chat', dumps(chat.serialize()))
    return {}