static void Main(string[] args) { try { config = new Config(); config.Load(); gameMenus = new GameMenus(); gameActions = new GameActions(); dbutil = new DBUtil(); ActiveUsers = new List<DBUtil.UData>(); ExternalAppAPI.CommsCallback callback = new Callback(); InstanceContext context = new InstanceContext(callback); client = new ExternalAppAPI.CommsClient(context); client.Connect("", "", SDK.Instance); Console.WriteLine("Connected"); Timer KeepAliveTimer = new Timer(new TimerCallback(KeepAlive), null, 3 * 60 * 1000, 3 * 60 * 1000); Console.WriteLine("Press <return> to disconnect"); Console.ReadLine(); for ( int j = ActiveUsers.Count - 1; j >= 0; j--) { dbutil.SaveData(ActiveUsers[j].mxitid); } KeepAliveTimer.Dispose(); client.Disconnect(); client.Close(); config.Save(); } catch (Exception e) { Console.WriteLine(e.ToString()); } Console.WriteLine("\n<Return> to exit\n"); Console.ReadLine(); }
public void Load() { FileStream fs = new FileStream("Config.xml", FileMode.Open, FileAccess.Read); XmlSerializer xs = new XmlSerializer(this.GetType()); try { Config ld = new Config(); ld = (Config)xs.Deserialize(fs); VersionMajor = ld.VersionMajor; VersionMinor = ld.VersionMinor; Admins = ld.Admins; ConnString = ld.ConnString; Notice = ld.Notice; } finally { fs.Close(); } Console.WriteLine("Config loaded"); }