How to use the ws4py.server.wsgiutils.WebSocketWSGIApplication function in ws4py

To help you get started, we’ve selected a few ws4py examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gbeced / pyalgotrade / testcases / websocket_server.py View on Github external
def run(self):
        def handler_cls_builder(*args, **kwargs):
            return self.__webSocketServerClass(*args, **kwargs)

        self.__server = simple_server.make_server(
            self.__host,
            self.__port,
            server_class=wsgirefserver.WSGIServer,
            handler_class=wsgirefserver.WebSocketWSGIRequestHandler,
            app=wsgiutils.WebSocketWSGIApplication(handler_cls=handler_cls_builder)
        )
        self.__server.initialize_websockets_manager()
        self.__server.serve_forever()
github bopo / mooquant / tests / websocket_server.py View on Github external
def run(self):
        def handler_cls_builder(*args, **kwargs):
            return self.__webSocketServerClass(*args, **kwargs)

        self.__server = simple_server.make_server(
            self.__host,
            self.__port,
            server_class=wsgirefserver.WSGIServer,
            handler_class=wsgirefserver.WebSocketWSGIRequestHandler,
            app=wsgiutils.WebSocketWSGIApplication(handler_cls=handler_cls_builder)
        )
        self.__server.initialize_websockets_manager()
        self.__server.serve_forever()
github Lawouach / WebSocket-for-Python / test / autobahn_test_servers.py View on Github external
def run_python_wsgi_async(host="127.0.0.1", port=9010, async=True):
    """
    Runs wsgi server on python 2.x with async middleware"
    """

    from wsgiref.simple_server import make_server
    from ws4py.websocket import EchoWebSocket
    from ws4py.server.wsgirefserver import WSGIServer, WebSocketWSGIRequestHandler
    from ws4py.server.wsgiutils import WebSocketWSGIApplication

    app = WebSocketWSGIApplication(handler_cls=EchoWebSocket)
    if async:
        def middleware(app):
            def later(environ, start_response):
                for part in app(environ, start_response):
                    yield part
            return later
        app = middleware(app)
    server = make_server(host, port, server_class=WSGIServer,
                         handler_class=WebSocketWSGIRequestHandler,
                         app=app)
    server.initialize_websockets_manager()
    server.serve_forever()
github domogik / domogik / src / domogik_packages / xpl / lib / wsuiserver.py View on Github external
# check free port
        for s in __ctrlServer__ :
            if s.port == port :
                if log : log.error("Creating WS server error, port %d allready used."  % port)
                raise WsUIServerException ("Creating WS server error, port %d allready used."  % port)
        self.buffer = []
        self.clients = set()
        self.fail_clients = set()
        self.running = False
        self.port = port
        self.cb_recept = cb_recept
        self.log = log
        self.server = None
        self.server = make_server('', port, server_class=WSGIServer,
                     handler_class=WebSocketWSGIRequestHandler,
                     app=WebSocketWSGIApplication(handler_cls=WebSocketsHandler))
        if not self.server : raise WsUIServerException('Error websocket server creation, check if there is any other running plugin instance.')
        self.server.initialize_websockets_manager()
        __ctrlServer__.append(self)
        servUI = threading.Thread(None, self.run, "th_WSserv_msg_to_ui", (), {} )
        servUI.start()
        time.sleep(0.1)
        if self.log : self.log.info('WebSocket server started on port : %d' %self.port)
        print "**************** WebSocket server is started on port %d ********************" %self.port
github leon196 / CookieEngine / blender-addon / demoscene.py View on Github external
def start_server(host, port):
    global wserver
    if wserver:
        return False

    wserver = make_server(host, port,
        server_class=WSGIServer,
        handler_class=WebSocketWSGIRequestHandler,
        app=WebSocketWSGIApplication(handler_cls=WebSocketApp)
    )
    wserver.initialize_websockets_manager()

    wserver_thread = threading.Thread(target=wserver.serve_forever)
    wserver_thread.daemon = True
    wserver_thread.start()

    bpy.app.handlers.frame_change_post.append(frame_change_post)
    bpy.app.handlers.load_post.append(load_post)
    bpy.app.handlers.save_post.append(save_post)

    return True
github JorgeGarciaIrazabal / WSHubsAPI / WSHubsAPI / Test / BasicServer.py View on Github external
def initServer():
    class BaseHub(Hub):
        def sendToAll(self, name, message):
            self.otherClients.onMessage(name,message)
            return len(self.otherClients)
        def timeout(self,timeout = 3):
            time.sleep(timeout)
            return True

    Hub.constructPythonFile("client")
    server = make_server('127.0.0.1', 9999, server_class=WSGIServer,
                         handler_class=WebSocketWSGIRequestHandler,
                         app=WebSocketWSGIApplication(handler_cls=ClientHandler))
    server.initialize_websockets_manager()
    server.serve_forever()
github filimonic / Kodi.Screensaver.TurnOffLGTV / resources / lib / ws4py / server / geventserver.py View on Github external
_WSGIServer.__init__(self, *args, **kwargs)
        self.pool = GEventWebSocketPool()

    def stop(self, *args, **kwargs):
        self.pool.clear()
        _WSGIServer.stop(self, *args, **kwargs)

if __name__ == '__main__':
    import os

    from ws4py import configure_logger
    configure_logger()

    from ws4py.websocket import EchoWebSocket
    server = WSGIServer(('127.0.0.1', 9000),
                        WebSocketWSGIApplication(handler_cls=EchoWebSocket))
    server.serve_forever()
github LCAV / easy-dsp / code-server.py View on Github external
self.scriptThread = Process(target = runCode, args = (message, self, self.q_popen))
            self.scriptThread.start()
        else:
            print "Kill Process"
            self.q_popen.get().kill()
            # print self.scriptThread.terminate()
            # print self.__popen.kill()

    def closed(self, code, reason=None):
        clients.remove(self)
        if hasattr(self, 'q_popen') and not self.q_popen.empty():
            self.q_popen.get().kill()

server = make_server('', 7320, server_class=WSGIServer,
                     handler_class=WebSocketWSGIRequestHandler,
                     app=WebSocketWSGIApplication(handler_cls=PythonDaemon))

def quit_everything(signal, frame):
    global server
    print 'Exiting...'
    server.server_close()
signal.signal(signal.SIGINT, quit_everything)

server.initialize_websockets_manager()
print "Listening..."
server.serve_forever()
github bq / web2board / src / web2board.py View on Github external
def initializeServerAndCommunicationProtocol(options):
    HubsInspector.inspectImplementedHubs()
    # do not call this line in executable
    if not utils.areWeFrozen():
        HubsInspector.constructJSFile(path="libs/WSCommunication/Clients")
    server = make_server(options.host, options.port, server_class=WSGIServer,
                         handler_class=WebSocketWSGIRequestHandler,
                         app=WebSocketWSGIApplication(handler_cls=ConnectionHandler))
    server.initialize_websockets_manager()
    return server