本文整理汇总了Python中Server.Server.server_close方法的典型用法代码示例。如果您正苦于以下问题:Python Server.server_close方法的具体用法?Python Server.server_close怎么用?Python Server.server_close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Server.Server
的用法示例。
在下文中一共展示了Server.server_close方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Server import Server [as 别名]
# 或者: from Server.Server import server_close [as 别名]
class Controller:
def __init__(self,view):
self.view = view;
self.server = Server();
self.client = None;
self.server_thread = None;
self.tk_thread = None;
def start_server(self,event):
# Get all inputs' current values
config = self.view.get_inputs();
# Set up the server
try:
self.client = MaxClient(config[2], int(config[3]))
self.server.setup_server(config,self.client);
self.view.info_text['fg'] = 'green'
self.view.server_input['state'] = "disabled";
self.view.port_input['state'] = "disabled";
self.view.max_server_input['state'] = "disabled";
self.view.max_port_input['state'] = "disabled";
self.view.switch(self.view.CONNECT)
self.view.status.set("Internet Server: Connected")
self.server_thread = threading.Thread(name='server',target=self.server.server_wait)
self.server_thread.setDaemon(True)
self.server_thread.start()
except ConnectionError:
self.view.status.set("Internet Server: Error")
self.view.info_text['fg'] = 'red'
self.view.switch(self.view.DISCONNECT)
# Tell the server the application intends to close the socket
def close_server(self,event):
self.view.switch(self.view.DISCONNECT)
self.view.server_input['state'] = "normal";
self.view.port_input['state'] = "normal";
self.view.max_server_input['state'] = "normal";
self.view.max_port_input['state'] = "normal";
self.view.info_text['fg'] = 'grey'
if(self.server.socketIO):
self.server.server_close()
# Quit the application
def quit(self):
if(self.server_thread):
self.close_server();
self.server.run = False;
self.server_thread.join();
self.view.master.destroy();