Exemplo n.º 1
0
class RedBarrelSocketIOWorker(RedBarrelWSGIWorker):
    """SocketIO Worker.

       Has a broadcaster + a SocketIO server
    """
    def on_init(self, conf):
        super(RedBarrelSocketIOWorker, self).on_init(conf)
        self.receive_port = conf.get('receive_port', 5000)
        self.push_port = conf.get('push_port', 5001)
        self.broadcaster = None

    def callback(self, msg):
        # TO IMPLEMENT XXX
        pass

    def broadcast(self, filter, msg):
        if self.broadcaster is None:
            return  # XXX warning ?
        self.broadcaster.broadcast("%s %s" % (filter, msg))

    def _get_server(self):
        pool = Pool(self.worker_connections)
        return RedBarrelSocketIOServer(self.socket,
                                       application=self.application,
                                       spawn=pool,
                                       worker=self,
                                       handler_class=RedBarrelSocketIOHandler,
                                       resource="socket.io",
                                       memory=True)

    def _after_start(self):
        if ZMQ_SUPPORTED:
            self.broadcaster = Client(self.receive_port, self.push_port,
                                      self.callback)

            self.broadcaster.start()

    def _after_stop(self):
        if ZMQ_SUPPORTED:
            self.broadcaster.stop()
Exemplo n.º 2
0
class RedBarrelSocketIOWorker(RedBarrelWSGIWorker):
    """SocketIO Worker.

       Has a broadcaster + a SocketIO server
    """
    def on_init(self, conf):
        super(RedBarrelSocketIOWorker, self).on_init(conf)
        self.receive_port = conf.get('receive_port', 5000)
        self.push_port = conf.get('push_port', 5001)
        self.broadcaster = None

    def callback(self, msg):
        # TO IMPLEMENT XXX
        pass

    def broadcast(self, filter, msg):
        if self.broadcaster is None:
            return   # XXX warning ?
        self.broadcaster.broadcast("%s %s" % (filter, msg))

    def _get_server(self):
        pool = Pool(self.worker_connections)
        return RedBarrelSocketIOServer(self.socket,
                                       application=self.application,
                                       spawn=pool, worker=self,
                                       handler_class=RedBarrelSocketIOHandler,
                                       resource="socket.io",
                                       memory=True)

    def _after_start(self):
        if ZMQ_SUPPORTED:
            self.broadcaster = Client(self.receive_port, self.push_port,
                                      self.callback)

            self.broadcaster.start()

    def _after_stop(self):
        if ZMQ_SUPPORTED:
            self.broadcaster.stop()
Exemplo n.º 3
0
    def _after_start(self):
        if ZMQ_SUPPORTED:
            self.broadcaster = Client(self.receive_port, self.push_port,
                                      self.callback)

            self.broadcaster.start()
Exemplo n.º 4
0
    def _after_start(self):
        if ZMQ_SUPPORTED:
            self.broadcaster = Client(self.receive_port, self.push_port,
                                      self.callback)

            self.broadcaster.start()