Example #1
0
class WebSocketBackend(object):
    def __init__(self, clust):
        self.clust = clust
        port = clust.websocket.get('port', 6769)
        self.server = SimpleWebSocketServer(clust.listening_addr, port, WebExporter)


    def run(self):
	self.server.serveforever()


    def get_info(self):
        return {'nb_connexions': len(self.server.connections)}
    

    def send_all(self, o):
        try:
            msg = json.dumps(o)
        except ValueError:
            return
        for client in self.server.connections.itervalues():
            try:
                client.sendMessage(msg)
            except Exception as exp:
                logger.error('Cannot send websocket message: %s' % exp, part='websocket')
Example #2
0
class WebSocketBackend(object):
    def __init__(self, clust):
        self.clust = clust
        self.server = SimpleWebSocketServer(clust.addr, clust.port + 100, WebExporter)


    def run(self):
	self.server.serveforever()


    def send_all(self, o):
        try:
            msg = json.dumps(o)
        except ValueError:
            print "BAD MESSAGE"
            return
        for client in self.server.connections.itervalues():
            print "SENDING"*100
            try:
                client.sendMessage(msg)
            except Exception as n:
                print n
            print "SENT DONE"*100
Example #3
0
 def __init__(self, clust):
     self.clust = clust
     port = clust.websocket.get('port', 6769)
     self.server = SimpleWebSocketServer(clust.listening_addr, port, WebExporter)
Example #4
0
 def __init__(self, clust):
     self.clust = clust
     self.server = SimpleWebSocketServer(clust.addr, clust.port + 100, WebExporter)
Example #5
0
def run(port=8000):
    server = SimpleWebSocketServer('', port, Socket)
    print('Socket server ready on port ' + str(port))
    server.serveforever()