本文整理匯總了Python中websocket_server.WebsocketServer.server_close方法的典型用法代碼示例。如果您正苦於以下問題:Python WebsocketServer.server_close方法的具體用法?Python WebsocketServer.server_close怎麽用?Python WebsocketServer.server_close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類websocket_server.WebsocketServer
的用法示例。
在下文中一共展示了WebsocketServer.server_close方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: server
# 需要導入模塊: from websocket_server import WebsocketServer [as 別名]
# 或者: from websocket_server.WebsocketServer import server_close [as 別名]
def server():
""" Returns the response of a server after"""
s = WebsocketServer(0, loglevel=logging.DEBUG)
server_thread = Thread(target=s.run_forever)
server_thread.daemon = True
server_thread.start()
yield s
s.server_close()
示例2: startServer
# 需要導入模塊: from websocket_server import WebsocketServer [as 別名]
# 或者: from websocket_server.WebsocketServer import server_close [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()