本文整理汇总了Python中websocket_server.WebsocketServer.shutdown方法的典型用法代码示例。如果您正苦于以下问题:Python WebsocketServer.shutdown方法的具体用法?Python WebsocketServer.shutdown怎么用?Python WebsocketServer.shutdown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类websocket_server.WebsocketServer
的用法示例。
在下文中一共展示了WebsocketServer.shutdown方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: startServer
# 需要导入模块: from websocket_server import WebsocketServer [as 别名]
# 或者: from websocket_server.WebsocketServer import shutdown [as 别名]
tty.setraw(sys.stdin.fileno())
ch = sys.stdin.read(1)
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
return ch
def startServer(server):
print("HMI signals listener was started\r")
server.set_fn_new_client(new_client)
server.set_fn_client_left(client_left)
server.set_fn_message_received(message_received)
server.run_forever()
def keyBoardEvent():
global server
char = ' '
while char != 'q':
char = getch()
server = WebsocketServer(8081)
serverThread = Thread(target = startServer, args = (server, ))
keyBoardThread = Thread(target = keyBoardEvent)
keyBoardThread.start()
serverThread.start()
keyBoardThread.join()
print("Closing server...")
server.shutdown()
server.server_close()