public void Unload() { //Stop service application ServiceApplication.Stop(); ServiceApplication = null; }
private static void Main(string[] args) { try { CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.GetCultureInfo("en-US"); // initialize Logger Logger.InitializeLogger(LogManager.GetLogger(typeof(Program))); Console.Title = @"N# - Master Server"; string ipAddress = ConfigurationManager.AppSettings["MasterIP"]; int port = Convert.ToInt32(ConfigurationManager.AppSettings["MasterPort"]); // initialize DB if (!DataAccessHelper.Initialize()) { Console.ReadLine(); return; } Logger.Log.Info(Language.Instance.GetMessageFromKey("CONFIG_LOADED")); try { // register EF -> GO and GO -> EF mappings RegisterMappings(); // configure Services and Service Host IScsServiceApplication server = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(ipAddress, port)); server.AddService <ICommunicationService, CommunicationService>(new CommunicationService()); server.ClientConnected += OnClientConnected; server.ClientDisconnected += OnClientDisconnected; WebApp.Start <Startup>(ConfigurationManager.AppSettings["WebAppURL"]); server.Start(); // AUTO SESSION KICK Observable.Interval(TimeSpan.FromMinutes(3)).Subscribe(x => { Parallel.ForEach( MsManager.Instance.ConnectedAccounts.Where(s => s.LastPulse.AddMinutes(3) <= DateTime.Now), connection => { CommunicationServiceClient.Instance.KickSession(connection.AccountId, null); }); }); CommunicationServiceClient.Instance.Authenticate(ConfigurationManager.AppSettings["MasterAuthKey"]); Logger.Log.Info(Language.Instance.GetMessageFromKey("STARTED")); Console.Title = $"[Nos#] Master - Players : {MsManager.Instance.ConnectedAccounts.Count}"; } catch (Exception ex) { Logger.Log.Error("General Error Server", ex); } } catch (Exception ex) { Logger.Log.Error("General Error", ex); Console.ReadKey(); } }
static void Main(string[] args) { int port; try { port = 9000; // Hard code test if (port <= 0 || port > 65536) { throw new Exception(port + " is not a valid TCP port number."); } } catch (Exception ex) { Console.WriteLine("TCP port must be a positive number. Exception detail: " + ex.Message); return; } try { _serviceApplication = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(port)); _msgService = new MsgService(); _serviceApplication.AddService <IMsgService, MsgService>(_msgService); _msgService.UserListChanged += msgService_UserListChanged; _serviceApplication.Start(); } catch (Exception ex) { Console.WriteLine("Service can not be started. Exception detail: " + ex.Message); return; } }
public static void Main(string[] args) { try { #if DEBUG _isDebug = true; #endif CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.GetCultureInfo("en-US"); Console.Title = $"OpenNos Chat Log Server{(_isDebug ? " Development Environment" : string.Empty)}"; bool ignoreStartupMessages = false; foreach (string arg in args) { switch (arg) { case "--nomsg": ignoreStartupMessages = true; break; } } //initialize Logger Logger.InitializeLogger(LogManager.GetLogger(typeof(Program))); int port = Convert.ToInt32(ConfigurationManager.AppSettings["ChatLogPort"]); if (!ignoreStartupMessages) { Assembly assembly = Assembly.GetExecutingAssembly(); FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location); string text = $"CHAT LOG SERVER v{fileVersionInfo.ProductVersion}dev - PORT : {port} by OpenNos Team"; int offset = (Console.WindowWidth / 2) + (text.Length / 2); string separator = new string('=', Console.WindowWidth); } Logger.Info(Language.Instance.GetMessageFromKey("CONFIG_LOADED")); try { //configure Services and Service Host string ipAddress = ConfigurationManager.AppSettings["ChatLogIP"]; IScsServiceApplication _server = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(ipAddress, port)); _server.AddService <IChatLogService, ChatLogService>(new ChatLogService()); _server.ClientConnected += OnClientConnected; _server.ClientDisconnected += OnClientDisconnected; _server.Start(); Logger.Info(Language.Instance.GetMessageFromKey("STARTED")); } catch (Exception ex) { Logger.Error("General Error Server", ex); } } catch (Exception ex) { Logger.Error("General Error", ex); Console.ReadKey(); } }
public NDistManagementServicesRunner(NDistConfig config, INDistManagementService managementService) { _config = config; _managementService = managementService; _scsServiceApplication = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(Convert.ToInt32(_config.GetSetting("ServerPort").Value))); _scsServiceApplication.AddService <INDistManagementService, NDistManagementService>((NDistManagementService)_managementService); }
public NDistManagementServicesRunner(NDistConfig config, INDistManagementService managementService) { _config = config; _managementService = managementService; _scsServiceApplication = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(Convert.ToInt32(_config.GetSetting("ServerPort").Value))); _scsServiceApplication.AddService<INDistManagementService, NDistManagementService>((NDistManagementService)_managementService); }
private void StopServer() { if (_server != null) { _server.Stop(); _server = null; _adminService = null; } }
/// <summary> /// Initilize launcher service /// </summary> public static void Init() { _lservice = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(ServicesConfigs.Default.LauncherService_ip, ServicesConfigs.Default.LauncherService_port)); _lservice.AddService <ILauncherContract, Bridge>(new Bridge()); _lservice.Start(); Log.Info("LauncherService started at {0}:{1}", ServicesConfigs.Default.LauncherService_ip, ServicesConfigs.Default.LauncherService_port); }
private static void Main(string[] args) { try { CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.GetCultureInfo("en-US"); // initialize Logger Logger.InitializeLogger(LogManager.GetLogger(typeof(Program))); Assembly assembly = Assembly.GetExecutingAssembly(); FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location); Console.Title = $"OpenNos Master Server v{fileVersionInfo.ProductVersion}dev"; string ipAddress = ConfigurationManager.AppSettings["MasterIP"]; int port = Convert.ToInt32(ConfigurationManager.AppSettings["MasterPort"]); string text = $"MASTER SERVER v{fileVersionInfo.ProductVersion}dev - PORT : {port} by OpenNos Team"; int offset = Console.WindowWidth / 2 + text.Length / 2; string separator = new string('=', Console.WindowWidth); Console.WriteLine(separator + string.Format("{0," + offset + "}\n", text) + separator); // initialize DB if (!DataAccessHelper.Initialize()) { Console.ReadLine(); return; } Logger.Log.Info(Language.Instance.GetMessageFromKey("CONFIG_LOADED")); try { // register EF -> GO and GO -> EF mappings RegisterMappings(); // configure Services and Service Host IScsServiceApplication server = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(ipAddress, port)); server.AddService <ICommunicationService, CommunicationService>(new CommunicationService()); server.ClientConnected += OnClientConnected; server.ClientDisconnected += OnClientDisconnected; WebApp.Start <Startup>(url: ConfigurationManager.AppSettings["WebAppURL"]); server.Start(); CommunicationServiceClient.Instance.Authenticate(ConfigurationManager.AppSettings["MasterAuthKey"]); Logger.Log.Info(Language.Instance.GetMessageFromKey("STARTED")); Console.Title = $"MASTER SERVER - Channels :{MSManager.Instance.WorldServers.Count} - Players : {MSManager.Instance.ConnectedAccounts.Count}"; } catch (Exception ex) { Logger.Log.Error("General Error Server", ex); } } catch (Exception ex) { Logger.Log.Error("General Error", ex); Console.ReadKey(); } }
public void Load(IDVDProfilerAPI api) { //Create a service application that runs on 10083 TCP port ServiceApplication = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(10083)); //Create a CalculatorService and add it to service application ServiceApplication.AddService <IDVDProfilerRemoteAccess, DVDProfilerRemoteAccess>(new DVDProfilerRemoteAccess(api)); //Start service application ServiceApplication.Start(); }
private void StartServer() { try { _serviceApplication = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(10048)); _bugTrackerService = new BugTrackerService(); _serviceApplication.AddService <IBugTrackerService, BugTrackerService>(_bugTrackerService); _bugTrackerService.UserListChanged += bugTracker_UserListChanged; _serviceApplication.Start(); } catch (Exception ex) { MessageBox.Show("Service can not be started. Exception detail: " + ex.Message); return; } }
public void StartListening(string ip, int port) { //Create a service application that runs on 8001 TCP port _serviceApplication = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(ip, port)); //Create a CoreNode RMI Service and add it to service application _serviceApplication.AddService <ICoreNodeRequestService, CoreNodeRequestService>(new CoreNodeRequestService()); //Start service application _serviceApplication.Start(); _serviceApplication.ClientConnected += Server_ClientConnected; _serviceApplication.ClientDisconnected += Server_ClientDisconnected; _log.Info(String.Format("Server CoreNode Sevice Listening at: ip {0} : port {1}", ip, port)); _log.Info("Switchlink.Switch.Service => CoreNode Sevice Running..."); }
public void StartListening() { //Create a service application that runs on 8002 TCP port _serviceApplication = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(Config.ServerIpAddress, Config.ServerPort)); //Create a HostNode RMI Service and add it to service application _serviceApplication.AddService <IHostNodeRequestService, HostNodeRequestService>(new HostNodeRequestService()); //Start service application _serviceApplication.Start(); _bank.CreatePartnerConnection(); _serviceApplication.ClientConnected += Server_ClientConnected; _serviceApplication.ClientDisconnected += Server_ClientDisconnected; _log.Info(String.Format("Server HostNode Sevice Listening at: ip {0} : port {1}", Config.ServerIpAddress, Config.ServerPort)); _log.Info("Switchlink.Switch.Service => HostNode Sevice Running..."); }
/// <summary> /// Initilize game service /// </summary> public void Init(string key) { _authKey = key; _gsservice = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(ServicesConfigs.Default.GameServiceIp, ServicesConfigs.Default.GameServicePort)); _gsservice.AddService<IGameServerContract, GsService>(this); _gsservice.ClientConnected += GsserviceOnClientConnected; _gsservice.ClientDisconnected += (sender, args) => { if (ConnectedServers.ContainsKey(args.Client)) ConnectedServers.Remove(args.Client); Log.Info("GameServer disconnected."); }; _gsservice.Start(); Log.Info("GameService started at {0}:{1}", ServicesConfigs.Default.GameServiceIp, ServicesConfigs.Default.GameServicePort); }
static void Main(string[] args) { try { _app = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(10048)); _app.ClientConnected += new EventHandler<ServiceClientEventArgs>(_app_ClientConnected); _app.ClientDisconnected +=new EventHandler<ServiceClientEventArgs>(_app_ClientDisconnected); _service = new ChatService(); _service.UserListChanged += new EventHandler(_service_UserListChanged); _app.AddService<IChatService, ChatService>(_service); _app.Start(); Console.WriteLine("Server Started"); Console.ReadKey(); } catch (Exception) { } }
private void startServerBtn_Click(object sender, EventArgs e) { ExaminationStudentsFilter firewall = new ExaminationStudentsFilter(checkBox1.Checked ? FilterationSecurityLevel.High : FilterationSecurityLevel.Moderate, studentPassTxtBox.Text, instructorPassTxtBox.Text, FirewallRules); server = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(int.Parse(portTxtBox.Text))); aService = new NetworkExamService(anExam, studentPassTxtBox.Text, ref aLogger, UpdateDetails, firewall); //Add Phone Book Service to service application server.AddService <INetworkExamService, NetworkExamService>(aService); //Start server server.Start(); //Wait user to stop server by pressing Enter aLogger.LogMessage( "Server Started Successfully", LogMsgType.Verbose); //Console.ReadLine(); //Stop server //server.Stop(); }
/// <summary> /// Initilize game service /// </summary> public void Init(string key) { _authKey = key; _gsservice = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(ServicesConfigs.Default.GameServiceIp, ServicesConfigs.Default.GameServicePort)); _gsservice.AddService <IGameServerContract, GsService>(this); _gsservice.ClientConnected += GsserviceOnClientConnected; _gsservice.ClientDisconnected += (sender, args) => { if (ConnectedServers.ContainsKey(args.Client)) { ConnectedServers.Remove(args.Client); } Log.Info("GameServer disconnected."); }; _gsservice.Start(); Log.Info("GameService started at {0}:{1}", ServicesConfigs.Default.GameServiceIp, ServicesConfigs.Default.GameServicePort); }
private void startServerProcesses() { // var examStringEncrypted = ExamHelper.GetRandomExamforTesting(int.Parse(numberOfQuestionsTxtBox.Text)); // var anExam = ExamHelper.GetExamFromByteArray(examStringEncrypted, "123456", "", FilterationSecurityLevel.Moderate); // aLogger.LogMessage($"Load Exam the contains {anExam.QuestionsList.Count} Questions. [File Size= {(Math.Round(examStringEncrypted.Length / 1024.00, 2)).ToString()} KB]", LogMsgType.Verbose); var exams = GetExams(NumberOfQuestionsInit, NumberOfQuestionsMax, QuestionsStep); var firewalls = GetFirewalls(NumberOfStudetnInit, NumberOfStudentsMax, "123456", "123456", StudentsStep, highSecChkBox.Checked ? FilterationSecurityLevel.High : FilterationSecurityLevel.Moderate); aService = new NetworkExamServicePerformanceTesting(exams, "123456", UpdateDetails, firewalls); foreach (var exam in exams) { aLogger.LogMessage($"[EXAM GENERATED: ==> details], NumberOfQs=[{exam.Key}]", LogMsgType.Verbose); } foreach (var firewall in firewalls) { aLogger.LogMessage($"[Firewall GENERATED: ==> details], NumberOfStudentsRules=[{firewall.Key}]", LogMsgType.Verbose); } //Create a service application that runs on 10083 TCP port serviceApplication = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(int.Parse(portTxtBox.Text))); aLogger.LogMessage($"Server Started", LogMsgType.Verbose); //Create a CalculatorService and add it to service application //serviceApplication.AddService<ICalculatorService, CalculatorService>(new CalculatorService()); //Add Phone Book Service to service application serviceApplication.AddService <INetworkExamServiceTesting, NetworkExamServicePerformanceTesting>(aService); //Start service application serviceApplication.Start(); aLogger.LogMessage("Server Started", LogMsgType.Verbose); }
/// <summary> /// Handles Client event of 'Start Server' button. /// </summary> /// <param name="sender">Source of event</param> /// <param name="e">Event arguments</param> private void btnStartServer_Click(object sender, RoutedEventArgs e) { //Get TCP port number from textbox int port; try { port = Convert.ToInt32(txtPort.Text); if (port <= 0 || port > 65536) { throw new Exception(port + " is not a valid TCP port number."); } } catch (Exception ex) { MessageBox.Show("TCP port must be a positive number. Exception detail: " + ex.Message); return; } try { _serviceApplication = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(port)); _communicationService = new CommunicationService(); _serviceApplication.AddService <ICommunicationService, CommunicationService>(_communicationService); _communicationService.ModuleListChanged += chatService_UserListChanged; _serviceApplication.Start(); } catch (Exception ex) { MessageBox.Show("Service can not be started. Exception detail: " + ex.Message); return; } btnStartServer.IsEnabled = false; btnStopServer.IsEnabled = true; txtPort.IsEnabled = false; }
/// <summary> /// Handles Client event of 'Start Server' button. /// </summary> /// <param name="sender">Source of event</param> /// <param name="e">Event arguments</param> private void btnStartServer_Click(object sender, RoutedEventArgs e) { //Get TCP port number from textbox int port; try { port = Convert.ToInt32(txtPort.Text); if (port <= 0 || port > 65536) { throw new Exception(port + " is not a valid TCP port number."); } } catch (Exception ex) { MessageBox.Show("TCP port must be a positive number. Exception detail: " + ex.Message); return; } try { _serviceApplication = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(port)); _communicationService = new CommunicationService(); _serviceApplication.AddService<ICommunicationService, CommunicationService>(_communicationService); _communicationService.ModuleListChanged += chatService_UserListChanged; _serviceApplication.Start(); } catch (Exception ex) { MessageBox.Show("Service can not be started. Exception detail: " + ex.Message); return; } btnStartServer.IsEnabled = false; btnStopServer.IsEnabled = true; txtPort.IsEnabled = false; }
private void StartServer() { var host = Settings.Default.connectionHost; _server = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(host, 442)); _adminService = new DataNormalizatorService(); _adminService.OnClientCollectActivated += ClientActivated; _adminService.OnClientCollectDeactivated += ClientDeactivated; _adminService.OnClientCrashed += RemoveUserFromCollectQueue; _adminService.OnCollectRequest += CollectRequest; _adminService.OnCollectFinished += CollectFinished; _adminService.OnAllCollectStopped += RemoveUserFromCollectQueue; _adminService.OnClientAddedNewSymbol += RefreshSymbols; _server.AddService <IDataNormalizatorService, DataNormalizatorService>(_adminService); try { _server.Start(); } catch (Exception e) { _server.Stop(); Console.Write(e.Message); } }
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("-------------------------------------------"); }
#pragma warning restore RCS1169, IDE0044, 649 #endregion #region Methods public static void Main(string[] args) { try { #if DEBUG _isDebug = true; #endif CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.GetCultureInfo("en-US"); Console.Title = $"OpenNos Master Server{(_isDebug ? " Development Environment" : string.Empty)}"; bool ignoreStartupMessages = false; bool ignoreTelemetry = false; foreach (string arg in args) { switch (arg) { case "--nomsg": ignoreStartupMessages = true; break; case "--notelemetry": ignoreTelemetry = true; break; } } // initialize Logger Logger.InitializeLogger(LogManager.GetLogger(typeof(Program))); int port = Convert.ToInt32(ConfigurationManager.AppSettings["MasterPort"]); if (!ignoreStartupMessages) { Assembly assembly = Assembly.GetExecutingAssembly(); FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location); string text = $"MASTER SERVER v{fileVersionInfo.ProductVersion}dev - PORT : {port} by OpenNos Team"; string text2 = $"Built on: {new DateTime(((fileVersionInfo.ProductBuildPart - 1) * TimeSpan.TicksPerDay) + (fileVersionInfo.ProductPrivatePart * TimeSpan.TicksPerSecond * 2)).AddYears(1999)}"; string text3 = $"Built by: {BuildInfo.BuildUser}@{BuildInfo.BuildHost} ({BuildInfo.BuildOS})"; int offset = (Console.WindowWidth / 2) + (text.Length / 2); int offset2 = (Console.WindowWidth / 2) + (text2.Length / 2); int offset3 = (Console.WindowWidth / 2) + (text3.Length / 2); string separator = new string('=', Console.WindowWidth); Console.WriteLine(separator + string.Format("{0," + offset + "}\n", text) + string.Format("{0," + offset2 + "}\n", text2) + string.Format("{0," + offset3 + "}\n", text3) + separator); } // initialize DB if (!DataAccessHelper.Initialize()) { Console.ReadLine(); return; } Logger.Info(Language.Instance.GetMessageFromKey("CONFIG_LOADED")); try { // configure Services and Service Host string ipAddress = ConfigurationManager.AppSettings["MasterIP"]; IScsServiceApplication server = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(ipAddress, port)); server.AddService <ICommunicationService, CommunicationService>(new CommunicationService()); server.AddService <IConfigurationService, ConfigurationService>(new ConfigurationService()); server.AddService <IMailService, MailService>(new MailService()); server.AddService <IMallService, MallService>(new MallService()); server.AddService <IAuthentificationService, AuthentificationService>(new AuthentificationService()); server.ClientConnected += OnClientConnected; server.ClientDisconnected += OnClientDisconnected; server.Start(); Logger.Info(Language.Instance.GetMessageFromKey("STARTED")); if (!ignoreTelemetry) { string guid = ((GuidAttribute)Assembly.GetAssembly(typeof(ScsServiceBuilder)).GetCustomAttributes(typeof(GuidAttribute), true)[0]).Value; Observable.Interval(TimeSpan.FromMinutes(5)).Subscribe(observer => { try { WebClient wc = new WebClient(); foreach (WorldServer world in MsManager.Instance.WorldServers) { System.Collections.Specialized.NameValueCollection reqparm = new System.Collections.Specialized.NameValueCollection { { "key", guid }, { "ip", world.Endpoint.IpAddress }, { nameof(port), world.Endpoint.TcpPort.ToString() }, { "server", world.WorldGroup }, { "channel", world.ChannelId.ToString() }, { "userCount", MsManager.Instance.ConnectedAccounts.CountLinq(c => c.ConnectedWorld?.Id == world.Id).ToString() } }; byte[] responsebytes = wc.UploadValues("https://mgmt.opennos.io/Statistics/SendStat", "POST", reqparm); string[] resp = Encoding.UTF8.GetString(responsebytes).Split(':'); if (resp[0] != "saved") { Logger.Error(new Exception($"Unable to send statistics to management Server. Please report this issue to the Developer: {resp[0]}")); } } wc.Dispose(); } catch (Exception ex) { Logger.Error(new Exception($"Unable to send statistics to management Server. Please report this issue to the Developer: {ex.Message}")); } }); } } catch (Exception ex) { Logger.Error("General Error Server", ex); } Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine($"[{DateTime.UtcNow.ToLongTimeString()}][MSG][Main]: Server running!"); Console.ResetColor(); } catch (Exception ex) { Logger.Error("General Error", ex); Console.ReadKey(); } }
private void btnInitialize_Click(object sender, EventArgs e) { string strPassword; m_strLoginID = txtAccount.Text.Trim(); strPassword = txtPassWord.Text.Trim(); //如果是拆分模式,就不用開啟QuoteLib if (bServerMode) { #region OrderLib // 初始化 Order Lib //Initialize SKOrderLib m_nCode = OrderReply.Functions.SKOrderLib_Initialize(m_strLoginID, strPassword); //if (m_nCode == 0) // MessageBox.Show("Initialize Success"); if (m_nCode == 2003) { MessageBox.Show("元件已初始過,無須重複執行"); } else if (m_nCode != 0) { MessageBox.Show("Initialize Fail:code " + GetApiCodeDefine(m_nCode)); return; } //Initialize Cert m_nCode = OrderReply.Functions.SKOrderLib_ReadCertByID(m_strLoginID); //if (m_nCode == 0) // MessageBox.Show("ReadCert Success"); //Get Account OrderReply.FOnGetBSTR fAccount = new OrderReply.FOnGetBSTR(OnAccount); m_nCode = OrderReply.Functions.RegisterOnAccountCallBack(fAccount); m_nCode = OrderReply.Functions.GetUserAccount(); //OrderAsync CallBack m_nCode = OrderReply.Functions.RegisterOnOrderAsyncReportCallBack(fOrderAsync); m_nCode = OrderReply.Functions.RegisterOnExecutionReportCallBack(fOnExecutionReport); #endregion #region ReplyLib //Initialize SKOrderLib m_nCode = OrderReply.Functions.SKReplyLib_Initialize(m_strLoginID, strPassword); //if (m_nCode == 0) // MessageBox.Show("SKReplyLib_Initialize Success"); if (m_nCode == 2003) { MessageBox.Show("元件已初始過,無須重複執行"); } else if (m_nCode != 0) { MessageBox.Show("SKReplyLib_Initialize Fail:code " + GetApiCodeDefine(m_nCode)); return; } //OnConnect CallBack m_nCode = OrderReply.Functions.RegisterOnConnectCallBack(fRConnect); //OnDisconnect CallBack m_nCode = OrderReply.Functions.RegisterOnDisconnectCallBack(fDisconnect); //OnData CallBack m_nCode = OrderReply.Functions.RegisterOnDataCallBack(fData); //OnComplete CallBack m_nCode = OrderReply.Functions.RegisterOnCompleteCallBack(fComplete); #endregion scserv = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(10083)); scserv.AddService<IOSQuoteService, JNAutoDayTrade_Strategy>(dayTradeSt); scserv.Start(); } else { #region QuoteLib //Initialize SKOrderLib m_nCode = Functions.SKOSQuoteLib_Initialize(m_strLoginID, strPassword); //m_Logger.Write("SKOSQuoteLib_Initialize Code:" + m_nCode.ToString()); if (m_nCode == 0) { Console.WriteLine("Initialize Success"); //lblMessage.Text = "元件初始化完成"; //btnConnect_Click(null, null); } else if (m_nCode == 2003) { //lblMessage.Text = "元件已初始過,無須重複執行"; } else { //lblMessage.Text = "元件初始化失敗 code " + GetApiCodeDefine(m_nCode); return; } m_nCode = Functions.SKOSQuoteLib_AttachConnectCallBack(fConnect); m_nCode = Functions.SKOSQuoteLib_AttachQuoteCallBack(fQuoteUpdate); m_nCode = Functions.SKOSQuoteLib_AttachTicksCallBack(fNotifyTicks); m_nCode = Functions.SKOSQuoteLib_AttachBest5CallBack(fOnNotifyBest5); m_nCode = Functions.SKOSQuoteLib_AttachServerTimeCallBack(fNotifyServerTime); m_nCode = Functions.SKOSQuoteLib_AttachHistoryTicksGetCallBack(fOnNotifyTicksGet); return; #endregion } if (m_nCode == 1) { //MessageBox.Show("Initialize Success"); //lblMessage.Text = "元件初始化完成"; btnConnect_Click(sender, e); this.timer2.Enabled = true; this.timer2.Interval = 100; this.timer2.Start(); } }
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(GamePlay.Default.DBConString); 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("-------------------------------------------"); }
#pragma warning restore IDE0044, RCS1169, 649 #endregion #region Methods internal static void Main(string[] args) { try { #if DEBUG _isDebug = true; #endif CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.GetCultureInfo("en-US"); Console.Title = $"OpenNos Bazaar Server{(_isDebug ? " Development Environment" : string.Empty)}"; bool ignoreStartupMessages = false; foreach (string arg in args) { switch (arg) { case "--nomsg": ignoreStartupMessages = true; break; } } //initialize Logger Logger.InitializeLogger(LogManager.GetLogger(typeof(Program))); int port = Convert.ToInt32(ConfigurationManager.AppSettings["BazaarServerPort"]); if (!ignoreStartupMessages) { Assembly assembly = Assembly.GetExecutingAssembly(); FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location); string text = $"BAZAAR SERVER v{fileVersionInfo.ProductVersion}dev - PORT : {port} by OpenNos Team"; int offset = (Console.WindowWidth / 2) + (text.Length / 2); string separator = new string('=', Console.WindowWidth); Console.WriteLine(separator + string.Format("{0," + offset + "}\n", text) + separator); } Logger.Info(Language.Instance.GetMessageFromKey("CONFIG_LOADED")); try { //configure Services and Service Host string ipAddress = ConfigurationManager.AppSettings["BazaarServerIP"]; IScsServiceApplication server = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(ipAddress, port)); server.AddService <IBazaarService, BazaarService>(new BazaarService()); if (BazaarManager.Instance.AuthentificatedClients.Count != 0) { // Do nothing, just verify that BazaarManager is initialized before anyone // can connect } server.ClientConnected += OnClientConnected; server.ClientDisconnected += OnClientDisconnected; server.Start(); Logger.Info(Language.Instance.GetMessageFromKey("STARTED")); } catch (Exception ex) { Logger.Error("General Error Server", ex); } } catch (Exception ex) { Logger.Error("General Error", ex); } Console.ReadKey(); }
/// <summary> /// Called when we have success logining to DB /// </summary> private void Logined() { ui_status_labelItem_host.Text = Settings.Default.connectionHost; _startControl.IsOpen = false; _server = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(_startControl.ui_textBoxX_host.Text,443)); _adminService = new DataAdminService(); _adminService.OnloggedInLog += ClientLoggedLog; _adminService.OnloggedOutLog += ClientLoggedOutLog; _adminService.OnsymbolListChanged += UpdateSymbolTable; _adminService.OngroupListChanged += UpdateGroupTable; _adminService.DClientCrashed += RefreshDaBusySymbols; _adminService.TClientCrashed += RefreshTicknetBusySymbols; _adminService.OnTNResponseAboutCollect += ActivateClient; _logService = new DataNetLogService(); _logService.abortedOperation += AbortedOperationLog; _logService.finishedOperation += FinishedOperationLog; _logService.startedOperation += StartedOperationLog; _logService.simpleMessage += SimpleMessageLog; _server.AddService<IDataAdminService, DataAdminService>(_adminService); _server.AddService<IDataNetLogService, DataNetLogService>(_logService); _adminService.ErrorReport += ErrorMonitor.AddError; //Start server try { _server.Start(); ServerlogoutFlag = false; new Thread(() => { Thread.Sleep(200); UpdateAllTables(); }).Start(); } catch(SocketException ex) { Console.WriteLine(ex); ToastNotification.Show(_startControl, ex.Message); } catch (TimeOutException ex) { Console.WriteLine(ex); MessageBox.Show(ex.Message, @"Sql Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } catch(IndexOutOfRangeException ex) { Console.WriteLine(ex); MessageBox.Show(String.Format("Thare are some troubles with table's structure.\n"+ "Maybe You have old version of tables.\n Please, drop tables"), @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } catch(Exception ex) { Console.WriteLine(ex); ToastNotification.Show(_startControl, @"Incorrect login parameters!"); } }
public static void Main(string[] args) { try { #if DEBUG _isDebug = true; #endif CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.GetCultureInfo("fr-FR"); Console.Title = $"NosTale Ventus - Master Server [Port: 4545 - Language: EN]"; bool ignoreStartupMessages = false; bool ignoreTelemetry = false; foreach (string arg in args) { switch (arg) { case "--nomsg": ignoreStartupMessages = true; break; case "--notelemetry": ignoreTelemetry = true; break; } } // initialize Logger Logger.InitializeLogger(LogManager.GetLogger(typeof(Program))); int port = Convert.ToInt32(ConfigurationManager.AppSettings["MasterPort"]); if (!ignoreStartupMessages) { Assembly assembly = Assembly.GetExecutingAssembly(); FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location); string text = $"- VENTUS -"; int offset = (Console.WindowWidth / 2) + (text.Length / 2); string separator = new string('=', Console.WindowWidth); Console.WriteLine(separator + string.Format("{0," + offset + "}\n", text) + separator); } // initialize DB if (!DataAccessHelper.Initialize()) { Console.ReadLine(); return; } Console.WriteLine("[Load] Config has been loaded"); try { // configure Services and Service Host string ipAddress = ConfigurationManager.AppSettings["MasterIP"]; IScsServiceApplication _server = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(ipAddress, port)); _server.AddService <ICommunicationService, CommunicationService>(new CommunicationService()); _server.AddService <IConfigurationService, ConfigurationService>(new ConfigurationService()); _server.AddService <IMailService, MailService>(new MailService()); _server.AddService <IMallService, MallService>(new MallService()); _server.AddService <IAuthentificationService, AuthentificationService>(new AuthentificationService()); _server.ClientConnected += OnClientConnected; _server.ClientDisconnected += OnClientDisconnected; _server.Start(); Console.WriteLine("[Start] Master Server has been started successfully"); Console.WriteLine($"[Info] Started at: {DateTime.Now}"); if (!ignoreTelemetry) { } } catch (Exception ex) { Logger.Error("General Error Server", ex); } } catch (Exception ex) { Logger.Error("General Error", ex); Console.ReadKey(); } }
public static void Main(string[] args) { try { #if DEBUG _isDebug = true; #endif CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.GetCultureInfo("en-US"); Console.Title = $"Switch Server{(_isDebug ? " TestServer Environment" : "")}"; bool ignoreStartupMessages = false; bool ignoreTelemetry = false; foreach (string arg in args) { switch (arg) { case "--nomsg": ignoreStartupMessages = true; break; case "--notelemetry": ignoreTelemetry = true; break; } } // initialize Logger Logger.InitializeLogger(LogManager.GetLogger(typeof(Program))); int port = Convert.ToInt32(ConfigurationManager.AppSettings["MasterPort"]); if (!ignoreStartupMessages) { Assembly assembly = Assembly.GetExecutingAssembly(); FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location); string text = $"TEST Switch Server v{fileVersionInfo.ProductVersion}dev - PORT : {port} by OpenNos Team"; int offset = (Console.WindowWidth / 2) + (text.Length / 2); string separator = new string('=', Console.WindowWidth); Console.WriteLine(separator + string.Format("{0," + offset + "}\n", text) + separator); } // initialize DB if (!DataAccessHelper.Initialize()) { Console.ReadLine(); return; } Logger.Info(Language.Instance.GetMessageFromKey("CONFIG_LOADED")); try { // configure Services and Service Host string ipAddress = ConfigurationManager.AppSettings["MasterIP"]; IScsServiceApplication _server = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(ipAddress, port)); _server.AddService <ICommunicationService, CommunicationService>(new CommunicationService()); _server.AddService <IConfigurationService, ConfigurationService>(new ConfigurationService()); _server.AddService <IMailService, MailService>(new MailService()); _server.AddService <IMallService, MallService>(new MallService()); _server.AddService <IAuthentificationService, AuthentificationService>(new AuthentificationService()); _server.ClientConnected += OnClientConnected; _server.ClientDisconnected += OnClientDisconnected; _server.Start(); Logger.Info(Language.Instance.GetMessageFromKey("STARTED")); if (!ignoreTelemetry) { } } catch (Exception ex) { Logger.Error("General Error Server", ex); } } catch (Exception ex) { Logger.Error("General Error", ex); Console.ReadKey(); } }
public static void Main(string[] args) { try { #if DEBUG _isDebug = true; #endif CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.GetCultureInfo("en-US"); bool ignoreStartupMessages = false; foreach (string arg in args) { switch (arg) { case "--nomsg": ignoreStartupMessages = true; break; case "--notelemetry": break; } } // initialize Logger Logger.InitializeLogger(LogManager.GetLogger(typeof(Program))); int port = Convert.ToInt32(ConfigurationManager.AppSettings["MasterPort"]); if (!ignoreStartupMessages) { Assembly assembly = Assembly.GetExecutingAssembly(); FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location); string text = $"Master v{fileVersionInfo.ProductVersion} - Puerto : {port} by Source#"; int offset = (Console.WindowWidth / 2) + (text.Length / 2); string separator = new string('=', Console.WindowWidth); Console.WriteLine(separator + string.Format("{0," + offset + "}\n", text) + separator); } // initialize DB if (!DataAccessHelper.Initialize()) { Console.ReadLine(); return; } Logger.Info(Language.Instance.GetMessageFromKey("CONFIG_LOADED")); try { // configure Services and Service Host string ipAddress = ConfigurationManager.AppSettings["MasterIP"]; IScsServiceApplication _server = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(ipAddress, port)); _server.AddService <ICommunicationService, CommunicationService>(new CommunicationService()); _server.AddService <IConfigurationService, ConfigurationService>(new ConfigurationService()); _server.AddService <IMailService, MailService>(new MailService()); _server.AddService <IMallService, MallService>(new MallService()); _server.AddService <IAdminToolService, AdminToolService>(new AdminToolService()); _server.AddService <IAuthentificationService, AuthentificationService>(new AuthentificationService()); _server.ClientConnected += onClientConnected; _server.ClientDisconnected += onClientDisconnected; _server.Start(); // AUTO SESSION KICK Observable.Interval(TimeSpan.FromMinutes(3)).Subscribe(x => { Parallel.ForEach( MSManager.Instance.ConnectedAccounts.Where(s => s.LastPulse.AddMinutes(3) <= DateTime.Now), connection => { CommunicationServiceClient.Instance.KickSession(connection.AccountId, null); }); }); Logger.Info(Language.Instance.GetMessageFromKey("STARTED")); Console.Title = $"[Source c#] Master - Jugadores : {MSManager.Instance.ConnectedAccounts.Count}"; } catch (Exception ex) { Logger.Error("General Error Server", ex); } } catch (Exception ex) { Logger.Error("General Error", ex); Console.ReadKey(); } }
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("----===== 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 void StartServer() { var host = Settings.Default.connectionHost; _server = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(host, 442)); _adminService = new DataNormalizatorService(); _adminService.OnClientCollectActivated += ClientActivated; _adminService.OnClientCollectDeactivated += ClientDeactivated; _adminService.OnClientCrashed += RemoveUserFromCollectQueue; _adminService.OnCollectRequest += CollectRequest; _adminService.OnCollectFinished += CollectFinished; _adminService.OnAllCollectStopped += RemoveUserFromCollectQueue; _adminService.OnClientAddedNewSymbol += RefreshSymbols; _server.AddService<IDataNormalizatorService, DataNormalizatorService>(_adminService); try { _server.Start(); } catch (Exception e) { _server.Stop(); Console.Write(e.Message); } }