public void Stop() { Running = false; Logging.Info("AresServer", "Chatroom server shutting down."); timer.Change(-1, -1); timer.Dispose(); Config.PropertyChanged -= Config_PropertyChanged; listener?.Dispose(); listener = null; tlslistener?.Dispose(); tlslistener = null; idpool.Clear(); Stats.Reset(); Channels.PropertyChanged -= OnChannelsPropertyChanged; Channels.Stop(); Channels.Channels.SaveModel(Path.Combine(Config.Directories.AppData, "channels.json")); lock (pending) { foreach (var sock in pending) { sock.Dispose();//suppress disconnect event } pending.Clear(); } foreach (var user in Users) { History.Add(user); user.Dispose();//suppress disconnect event } Users.Clear(); History.Admin.Save();//admin are saved separate from history History.SaveModel(Path.Combine(Config.Directories.AppData, "history.json")); Logging.Info("AresServer", "Chatroom server stopped."); }
public void Stop() { timer.Change(-1, -1); timer.Dispose(); config.PropertyChanged -= Config_PropertyChanged; listener.Dispose(); listener = null; idpool.Clear(); stats.Reset(); channels.Stop(); RaisePropertyChanged(() => Running); lock (pending) { foreach (var sock in pending) { sock.Dispose();//suppress disconnect event } pending.Clear(); } lock (users.SyncRoot) { foreach (var user in users) { history.Add(user); user.Dispose();//suppress disconnect event } users.Clear(); } history.Save(); }