public const int LogoutTimeout = 1; //TODO: 10 public static void TryAuthorize(IConnection connection, string accountName, string session) { //TODO: Session check AccountService.Authorized(connection, accountName); FeedbackService.OnAuthorized(connection); InformerService.OnAccountAuthed(accountName); }
public void Error() { var logger = new Mock <ILogger>(); var obj = new InformerService(logger.Object); obj.LogError("test error"); logger.Verify(x => x.Error("test error"), Times.Once); }
public void Trace() { var logger = new Mock <ILogger>(); var obj = new InformerService(logger.Object); obj.LogTrace("test trace"); logger.Verify(x => x.Trace("test trace"), Times.Once); }
public void Debug() { var logger = new Mock <ILogger>(); var obj = new InformerService(logger.Object); obj.LogDebug("test debug"); logger.Verify(x => x.Debug("test debug"), Times.Once); }
public static void ClientDisconnected(IConnection connection) { if (connection.Account != null) { InformerService.OnAccountDiconnected(connection.Account.Name); } if (connection.Account != null && connection.Player != null) { Player player = connection.Player; new DelayedAction(() => PlayerLogic.PlayerEndGame(player), LogoutTimeout * 1000); } }
public static void PacketSent(Account account, string name, byte[] buffer) { if (account == null) { return; } const string callStack = ""; /*StackTrace stackTrace = new StackTrace(true); * var frames = stackTrace.GetFrames(); * * if (frames != null) * foreach (var frame in frames) * callStack += string.Format("{0}\n", frame);*/ InformerService.PacketSent(account.Name, name, buffer, callStack); }
public static void PacketReceived(Account account, Type type, byte[] buffer) { if (account == null) { return; } StackTrace stackTrace = new StackTrace(true); var frames = stackTrace.GetFrames(); string callStack = ""; if (frames != null) { foreach (var frame in frames) { callStack += string.Format("{0}\n", frame); } } InformerService.PacketReceived(account.Name, type != null ? type.Name : "unk", buffer, callStack); }
private static void RunServer() { Data.Data.DataPath = "data/"; Stopwatch sw = Stopwatch.StartNew(); AppDomain.CurrentDomain.UnhandledException += UnhandledException; Console.WriteLine("----===== Tera-Project C# GameServer Emulator =====----\n\n"); Console.WriteLine("Starting Game Server!\n" + "-------------------------------------------"); TcpServer = new TcpServer("*", Config.GetServerPort(), Config.GetServerMaxCon()); Connection.SendAllThread.Start(); OpCodes.Init(); Console.WriteLine("OpCodes - Revision 1725 initialized!\n" + "-------------------------------------------\n"); #region global_components //services FeedbackService = new FeedbackService(); AccountService = new AccountService(); PlayerService = new PlayerService(); MapService = new MapService(); ChatService = new ChatService(); VisibleService = new VisibleService(); ControllerService = new ControllerService(); CraftService = new CraftService(); ItemService = new ItemService(); AiService = new AiService(); GeoService = new GeoService(); StatsService = new StatsService(); ObserverService = new ObserverService(); AreaService = new AreaService(); InformerService = new InformerService(); TeleportService = new TeleportService(); PartyService = new PartyService(); SkillsLearnService = new SkillsLearnService(); CraftLearnService = new CraftLearnService(); GuildService = new GuildService(); EmotionService = new EmotionService(); RelationService = new RelationService(); DuelService = new DuelService(); StorageService = new StorageService(); TradeService = new TradeService(); MountService = new MountService(); //engines ActionEngine = new ActionEngine.ActionEngine(); AdminEngine = new AdminEngine.AdminEngine(); SkillEngine = new SkillEngine.SkillEngine(); QuestEngine = new QuestEngine.QuestEngine(); #endregion GlobalLogic.ServerStart("SERVER=" + Config.GetDatabaseHost() + ";DATABASE=" + Config.GetDatabaseName() + ";UID=" + Config.GetDatabaseUser() + ";PASSWORD="******";PORT=" + Config.GetDatabasePort() + ";charset=utf8"); Console.WriteLine("-------------------------------------------\n" + "Loading Tcp Service.\n" + "-------------------------------------------"); TcpServer.BeginListening(); try { ServiceApplication = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(23232)); ServiceApplication.AddService <IInformerService, InformerService>((InformerService)InformerService); ServiceApplication.Start(); Log.Info("InformerService started at *:23232."); var webservices = new ServiceManager(); webservices.Run(); } catch (Exception ex) { Log.ErrorException("InformerService can not be started.", ex); } sw.Stop(); Console.WriteLine("-------------------------------------------"); Console.WriteLine(" Server start in {0}", (sw.ElapsedMilliseconds / 1000.0).ToString("0.00s")); Console.WriteLine("-------------------------------------------"); }
private static void RunServer() { Data.Data.DataPath = "data/"; Stopwatch sw = Stopwatch.StartNew(); AppDomain.CurrentDomain.UnhandledException += UnhandledException; Console.WriteLine("----===== GameServer =====----\n\n" + "Starting game server\n\n" + "Loading data files.\n" + "-------------------------------------------"); TcpServer = new TcpServer("*", 11101, 1000); Connection.SendAllThread.Start(); OpCodes.Init(); #region global_components //services FeedbackService = new FeedbackService(); AccountService = new AccountService(); PlayerService = new PlayerService(); MapService = new MapService(); ChatService = new ChatService(); VisibleService = new VisibleService(); ControllerService = new ControllerService(); CraftService = new CraftService(); ItemService = new ItemService(); AiService = new AiService(); GeoService = new GeoService(); StatsService = new StatsService(); ObserverService = new ObserverService(); AreaService = new AreaService(); InformerService = new InformerService(); TeleportService = new TeleportService(); PartyService = new PartyService(); SkillsLearnService = new SkillsLearnService(); CraftLearnService = new CraftLearnService(); GuildService = new GuildService(); EmotionService = new EmotionService(); RelationService = new RelationService(); DuelService = new DuelService(); StorageService = new StorageService(); TradeService = new TradeService(); MountService = new MountService(); //engines ActionEngine = new ActionEngine.ActionEngine(); AdminEngine = new AdminEngine.AdminEngine(); SkillEngine = new SkillEngine.SkillEngine(); QuestEngine = new QuestEngine.QuestEngine(); #endregion GlobalLogic.ServerStart(); TcpServer.BeginListening(); try { ServiceApplication = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(23232)); ServiceApplication.AddService <IInformerService, InformerService>((InformerService)InformerService); ServiceApplication.Start(); Log.Info("InformerService started at *:23232."); } catch (Exception ex) { Log.ErrorException("InformerService can not be started.", ex); } sw.Stop(); Console.WriteLine("-------------------------------------------"); Console.WriteLine(" Server start in {0}", (sw.ElapsedMilliseconds / 1000.0).ToString("0.00s")); Console.WriteLine("-------------------------------------------"); }