How to use the ws4py.server.wsgirefserver.WebSocketWSGIRequestHandler 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 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
github JorgeGarciaIrazabal / WSHubsAPI / WSHubsAPI / examples / Clients / ws4pyServer.py View on Github external
from ws4py.server.wsgirefserver import WSGIServer, WebSocketWSGIRequestHandler
from wshubsapi.Hub import Hub
from ws4py.server.wsgiutils import WebSocketWSGIApplication

logging.config.dictConfig(json.load(open('logging.json')))
log = logging.getLogger(__name__)

if __name__ == '__main__':
    importlib.import_module("ChatHub")  # necessary to add this import for code inspection
    # construct the necessary client files in the specified path
    Hub.constructPythonFile("../Clients/_static")
    Hub.constructJSFile("../Clients/_static")
    # Hub.constructJAVAFile("tornado.WSHubsApi", "../Clients/_static")

    server = make_server('127.0.0.1', 8888, server_class=WSGIServer,
                         handler_class=WebSocketWSGIRequestHandler,
                         app=WebSocketWSGIApplication(handler_cls=ClientHandler))
    server.initialize_websockets_manager()
    log.debug("starting...")
    target = server.serve_forever()
github waveform80 / pistreaming / server.py View on Github external
def main():
    print('Initializing camera')
    with picamera.PiCamera() as camera:
        camera.resolution = (WIDTH, HEIGHT)
        camera.framerate = FRAMERATE
        camera.vflip = VFLIP # flips image rightside up, as needed
        camera.hflip = HFLIP # flips image left-right, as needed
        sleep(1) # camera warm-up time
        print('Initializing websockets server on port %d' % WS_PORT)
        WebSocketWSGIHandler.http_version = '1.1'
        websocket_server = make_server(
            '', WS_PORT,
            server_class=WSGIServer,
            handler_class=WebSocketWSGIRequestHandler,
            app=WebSocketWSGIApplication(handler_cls=StreamingWebSocket))
        websocket_server.initialize_websockets_manager()
        websocket_thread = Thread(target=websocket_server.serve_forever)
        print('Initializing HTTP server on port %d' % HTTP_PORT)
        http_server = StreamingHttpServer()
        http_thread = Thread(target=http_server.serve_forever)
        print('Initializing broadcast thread')
        output = BroadcastOutput(camera)
        broadcast_thread = BroadcastThread(output.converter, websocket_server)
        print('Starting recording')
        camera.start_recording(output, 'yuv')
        try:
            print('Starting websockets thread')
            websocket_thread.start()
            print('Starting HTTP server thread')
            http_thread.start()
github LCAV / easy-dsp / browserinterface.py View on Github external
def start_server(port):
    global server
    server = make_server('', port, server_class=WSGIServer,
                         handler_class=WebSocketWSGIRequestHandler,
                         app=WebSocketWSGIApplication(handler_cls=WSServer))
    server.initialize_websockets_manager()
    server.serve_forever()
github mirumee / chromedebug / chromedebug / thread.py View on Github external
def run(self):
        from . import server
        self.server = make_server(
            '', 9222, server_class=WSGIServer,
            handler_class=WebSocketWSGIRequestHandler,
            app=WebSocketWSGIApplication(handler_cls=server.DebuggerWebSocket))
        sys.stderr.write(
            'Navigate to chrome://devtools/devtools.html?ws=0.0.0.0:9222\n')
        self.server.initialize_websockets_manager()
        self.server.serve_forever()
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 / examples / Servers / ws4pyServer.py View on Github external
from wshubsapi.Hub import Hub
from ws4py.server.wsgiutils import WebSocketWSGIApplication
if __name__ == '__main__':

    class ChatHub(Hub):
        def sendToAll(self, name, message):
            allConnectedClients = self._get_clients_holder().get_all_clients()
            #onMessage function has to be defined in the client side
            allConnectedClients.on_message(name, message)
            return "Sent to %d clients" % len(allConnectedClients)

    HubsInspector.inspect_implemented_hubs() #setup api
    HubsInspector.construct_python_file("../Clients/_static") #only if you will use a python client
    HubsInspector.construct_js_file("../Clients/_static") #only if you will use a js client
    server = make_server('127.0.0.1', 8888, server_class=WSGIServer,
                         handler_class=WebSocketWSGIRequestHandler,
                         app=WebSocketWSGIApplication(handler_cls=ConnectionHandler))
    server.initialize_websockets_manager()
    server.serve_forever()
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 JorgeGarciaIrazabal / WSHubsAPI / wshubsapi / POC / ws4pyServer.py View on Github external
import logging.config

logging.config.dictConfig(json.load(open('logging.json')))
log = logging.getLogger(__name__)

if __name__ == '__main__':
    importlib.import_module("ChatHub")  # necessary to add this import for code inspection
    importlib.import_module("DB_API")  # necessary to add this import for code inspection
    # construct the necessary client files in the specified path
    HubsInspector.inspect_implemented_hubs()
    HubsInspector.construct_python_file()
    # Hub.constructJAVAFile("tornado.WSHubsApi", "../Clients/_static") in beta
    # HubsInspector.constructCppFile("../Clients/_static") in alpha

    server = make_server('127.0.0.1', 8888, server_class=WSGIServer,
                         handler_class=WebSocketWSGIRequestHandler,
                         app=WebSocketWSGIApplication(handler_cls=ConnectionHandler))
    server.initialize_websockets_manager()

    log.debug("starting...")
    target = server.serve_forever()