0

我使用 gevent-socketio 库,需要发送消息post_save

...
def post_save(self, obj, created=False):
    // broadcast message with data(obj) to channel

我怎样才能做到这一点?

编辑:

有这个例子:

from socketio.namespace import BaseNamespace
from socketio.mixins import BroadcastMixin
from socketio.sdjango import namespace


@namespace('/document')
class DocumentNamespace(BaseNamespace, BroadcastMixin):

    def recv_connect(self):
        print "CONNECTED"

    def on_join(self, msg):
        self.broadcast_event('poruka', msg)

        print 'JOIN'
        return True

    def broadcast_msg(self, channel, msg):
        self.broadcast_event(channel, msg)

此示例在客户端连接或向服务器发送消息时进行侦听,但我需要将我的方法广播post_save到客户端..

4

0 回答 0