當前位置: 首頁>>代碼示例>>Python>>正文


Python WebsocketServer.server_close方法代碼示例

本文整理匯總了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()
開發者ID:Pithikos,項目名稱:python-websocket-server,代碼行數:10,代碼來源:utils.py

示例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()
開發者ID:smartdevicelink,項目名稱:sdl_hmi,代碼行數:32,代碼來源:start_server.py


注:本文中的websocket_server.WebsocketServer.server_close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。