Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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()
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
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()
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()
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()
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()
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
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()
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()
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()