/// <summary> /// Stop handler for rebooting /// </summary> public void CloseHandler() { Thread.Sleep(1000); ChatServer.OnClose -= CloseHandler; ChatServer = new ServerListener(); UdpChatServer = new UdpServerListener(); ChatServerInit(); ChatServer.StartListenAsync(Server.Address, Server.Port); StartUdpServer(); }
void ChatServerInit() { lock (UdpChatServer) { UdpChatServer.OnLog += Log; } lock(ChatServer) { ChatServer.Users.Clear(); ChatServer.OnLog += Log; ChatServer.OnUserState += ChatServer_OnUserState; ChatServer.OnTalkOccur += ChatServer_OnTalkOccur; ChatServer.OnClose += () => { EvtLog("Server was closed"); ChatServer = new ServerListener(); ChatServerInit(); }; } }