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(); } }
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(); } }
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); }
/// <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(); }
static void Main(string[] args) { var serviceApplication = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(4040)); serviceApplication.AddService <ITaxiService, TaxiService>(new TaxiService()); serviceApplication.Start(); Console.WriteLine("Server started... Push enter for stop."); Console.ReadLine(); serviceApplication.Stop(); }
static void Main(string[] args) { var server = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(10048)); server.AddService <IVoldeMoveisService, VoldemoveisServices>(new VoldemoveisServices()); server.Start(); Console.WriteLine( "Servidor Iniciado com sucesso. Pressione Enter para parar..."); Console.ReadLine(); server.Stop(); }
static void Main(string[] args) { var server = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(10047)); IDatabase database = new DataBase(); DriverServer driverServer = new DriverServer(database); server.AddService <IDriverServer, DriverServer>(driverServer); ManagerServer managerServer = new ManagerServer(database); server.AddService <IManagerServer, ManagerServer>(managerServer); server.Start(); OrderEmulator emulator = new OrderEmulator(driverServer); emulator.stopTimer(); Console.WriteLine("Enter:\n" + "0 - exit\n" + "2 - generate order\n"); String line; do { //Wait user to stop server by pressing Enter line = Console.ReadLine(); switch (line) { case "1": break; case "2": emulator.generateOrder(); break; case "3": new Map(); break; } } while (!line.Equals("0")); //Stop server server.Stop(); }
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; } }
static void Main(string[] args) { var server = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(10088)); /* * Only run-time errors are here,if service and interface do not correspond. */ server.AddService(Type.GetType("CommonLib.ISay,CommonLib"), Activator.CreateInstance(Type.GetType("CommonLib.SayHello,CommonLib"))); server.Start(); Console.WriteLine("Press enter to stop server application"); Console.ReadLine(); server.Stop(); }
static void Main() { //Create a service application that runs on 10083 TCP port var serviceApplication = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(10083)); //Create a CalculatorService and add it to service application serviceApplication.AddService <ICalculatorService, CalculatorService>(new CalculatorService()); //Start service application serviceApplication.Start(); Console.WriteLine("Calculator service is started. Press enter to stop..."); Console.ReadLine(); //Stop service application serviceApplication.Stop(); }
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..."); }
static void Main(string[] args) { var server = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(10088)); ProxyGenerator proxyGenerator = new ProxyGenerator(); object say = proxyGenerator.CreateClassProxy(typeof(BaseObject), new Type[] { typeof(ISay) }, ProxyGenerationOptions.Default, new object[] { new SayHello() }, new IInterceptor[] { new ExternInterceptor(), new ServerInterceptor() }); server.AddService(typeof(ISay), say); server.Start(); Console.WriteLine("Press enter to stop server application"); Console.ReadLine(); server.Stop(); }
internal static void Main(string[] args) { if (Mutex.WaitOne(TimeSpan.Zero, true)) { var server = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(MonetSettings.Tcp.Port)); server.AddService <IMonetDbtcpService, MonetDbtcpService>(new MonetDbtcpService()); server.ClientConnected += delegate(object sender, ServiceClientEventArgs eventArgs) { LoggerHelper.Write(LoggerOption.Info, @"Client#{0} connected", eventArgs.Client.ClientId); }; server.ClientDisconnected += delegate(object sender, ServiceClientEventArgs eventArgs) { LoggerHelper.Write(LoggerOption.Warning, @"Client#{0} disconnected", eventArgs.Client.ClientId); }; //Start server server.Start(); //Wait user to stop server by pressing Enter LoggerHelper.Write(LoggerOption.Info, @"MonetDB Api Server started successfully."); LoggerHelper.Write(LoggerOption.Warning, @"Press enter to stop..."); if (Console.ReadKey().Key == ConsoleKey.Enter) { //remove server server.RemoveService <IMonetDbtcpService>(); //Stop server server.Stop(); } Mutex.ReleaseMutex(); } else { LoggerHelper.Write(LoggerOption.Warning, @"Only one instance at a time"); Console.ReadLine(); Environment.Exit(Environment.ExitCode); } }
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..."); }
static void Main() { //Create a Scs Service application that runs on 10048 TCP port. var server = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(10048)); //Add Phone Book Service to service application server.AddService <IPhoneBookService, PhoneBookService>(new PhoneBookService()); //Start server server.Start(); //Wait user to stop server by pressing Enter Console.WriteLine("Phone Book Server started successfully. Press enter to stop..."); Console.ReadLine(); //Stop server server.Stop(); }
static void Main(string[] args) { Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("Serwer: UnityPoker"); Console.WriteLine("Data kompilacji: " + Helper.RetrieveLinkerTimestamp().ToString()); //Startujemy interfejs www //var listeningOn = "http://*:1337/"; //var appHost = new AppHost() // .Init() // .Start(listeningOn); //Uruchomienie serwera SCS var server = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(10048)); server.AddService <IPokerService, PokerService>(PokerService.Instance); server.Start(); //Startujemy apliakcje konsolową Console.SetOut(new PrefixedWriter()); Console.ReadLine(); }
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; }
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("----===== 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("-------------------------------------------"); }
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(); } }
#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(); } }
static void Main(string[] args) { var server = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(1048)); }
#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(); }
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(); } }