public static void Main() { //init instances: LogControl logControl = new LogControl(); SystemControl sysControl = new SystemControl(logControl); ReplayManager replayManager = new ReplayManager(); SessionIdHandler sidHandler = new SessionIdHandler(); GameCenter gameCenter = new GameCenter(sysControl, logControl, replayManager, sidHandler); var commHandler = CommunicationHandler.GetInstance(); MessageEventHandler eventHandler = new MessageEventHandler(gameCenter, sysControl, logControl, replayManager, sidHandler); gameCenter.SetMessageHandler(eventHandler); var webEventHandler = new WebEventHandler(new ServerEventHandler(sidHandler, null, gameCenter, sysControl, logControl, replayManager, null)); WebCommHandler webCommHandler = new WebCommHandler(webEventHandler); Task commTask = Task.Factory.StartNew(commHandler.Start); Task webCommTask = Task.Factory.StartNew(webCommHandler.Start); Console.WriteLine("starting comm"); Task eventTask = Task.Factory.StartNew(eventHandler.HandleIncomingMsgs); commTask.Wait(); webCommTask.Wait(); }
// Implementation according to the Singleton Pattern public static GameCenter GetGameCenter(string dbName = "TexasDatabase") { return(_instance ?? (_instance = new GameCenter(dbName))); }