public virtual bool Initialize() { IBootstrap bootstrap = BootstrapFactory.CreateBootstrap(); if (!bootstrap.Initialize()) { return(false); } IWorkItem item = bootstrap.AppServers.FirstOrDefault(server => server.Name == Name); m_HL7Server = item as HL7Server; if (m_HL7Server == null) { return(false); } m_HL7Server.Logger.Debug("the Server side is initializing"); HL7SocketServiceConfig config = bootstrap.Config as HL7SocketServiceConfig; if (config == null && config.ProtocolConfig == null) { return(false); } m_HL7Protocol.Config = config.ProtocolConfig; return(Initialize(m_HL7Server, m_HL7Protocol)); }
public static void Init() { Console.WriteLine("Welcome to SuperSocket SocketService"); IBootstrap bootstrap = BootstrapFactory.CreateBootstrap(); if (!bootstrap.Initialize()) { Console.WriteLine("初始化"); Console.ReadKey(); return; } Console.WriteLine("启动中"); var result = bootstrap.Start(); foreach (var server in bootstrap.AppServers) { if (server.State == ServerState.Running) { Console.WriteLine($"- {server.Name} 运行中"); } else { Console.WriteLine($"- {server.Name} 启动失败"); } } }
static void Main(string[] args) { #region 初始化Socket IBootstrap bootstrap = BootstrapFactory.CreateBootstrap(); if (!bootstrap.Initialize()) { Console.WriteLine(DateTime.Now + ":Socket初始化失败\r\n"); return; } var result = bootstrap.Start(); foreach (var server in bootstrap.AppServers) { if (server.State == ServerState.Running) { Console.WriteLine(DateTime.Now + ":serverName为:" + server.Name + "Socket运行中\r\n"); } else { Console.WriteLine(DateTime.Now + ":serverName为:" + server.Name + "Socket启动失败\r\n"); } } Console.ReadKey(); #endregion }
public void Setup() { m_Bootstrap = BootstrapFactory.CreateBootstrapFromConfigFile("SuperSocket.config"); Assert.IsTrue(m_Bootstrap.Initialize()); m_Port = ((IAppServer)m_Bootstrap.AppServers.FirstOrDefault()).Config.Port; Assert.AreEqual(StartResult.Success, m_Bootstrap.Start()); }
public static void Init() { try { //支持通过配置文件读取对服务启动 IBootstrap bootstrap = BootstrapFactory.CreateBootstrap(); if (!bootstrap.Initialize()) { Console.WriteLine("初始化失败"); Console.ReadKey(); return; } Console.WriteLine("准备启动服务"); var result = bootstrap.Start(); foreach (var server in bootstrap.AppServers) { if (server.State == ServerState.Running) { Console.WriteLine($"{server.Name}运行中"); } else { Console.WriteLine($"{server.Name}启动失败"); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.Read(); }
private void RibbonForm1_Load(object sender, EventArgs e) { Logger.LogForm = this; this.Messages = new List <LogMessage>(); this.TimerClear = new Timer { Interval = this.Interval * 1000 }; this.TimerRefresh = new Timer { Interval = this.Interval * 1000 }; this.TimerClear.Tick += (m, n) => { RemoveData(); }; this.TimerRefresh.Tick += (m, n) => { RefreshData(); }; this.TimerClear.Start(); this.TimerRefresh.Start(); var bootstrap = BootstrapFactory.CreateBootstrap(); if (!bootstrap.Initialize()) { m_txtStatus.Caption = "失败"; return; } var result = bootstrap.Start(); m_txtStatus.Caption = "服务启动成功"; }
public TDerivered Child(Func <BootstrapFactory <TModel>, BuilderBase> html) { BootstrapFactory <TModel> factory = new BootstrapFactory <TModel>(this.Model); this.Html(html(factory).ToHtmlString()); return(this as TDerivered); }
static void Main(string[] args) { var bootstrap = BootstrapFactory.CreateBootstrap(); if (!bootstrap.Initialize()) { LOGGER.Error("初始化失败!"); Console.ReadKey(); return; } if (bootstrap.Start() == SuperSocket.SocketBase.StartResult.Failed) { LOGGER.Error("协议解析器启动失败!"); Console.ReadKey(); return; } RainfallServer server = bootstrap.AppServers.SingleOrDefault(s => s.Name == "RainfallServer") as RainfallServer; if (server == null) { LOGGER.Error("协议解析器服务器未找到."); return; } LOGGER.Debug("输入任意键结束..."); Console.ReadLine(); bootstrap.Stop(); }
static void InitSocket() { var simpleCfg = IocUnity.Get <SimpleSocketConfig>(); Stopwatch startWatch = new Stopwatch(); startWatch.Start(); simpleCfg.Mode = CSuperSocket.SocketBase.SocketMode.Udp; var bootstrap = BootstrapFactory.CreateBootstrapFromServerCfg(simpleCfg); startWatch.Stop(); Console.WriteLine("CSpuerTcp初始化工厂耗时:{0}ms", startWatch.ElapsedMilliseconds); startWatch.Reset(); startWatch.Start(); var isSuccess = bootstrap.Initialize(); startWatch.Stop(); Console.WriteLine("CSpuerTcp启动耗时:{0}ms", startWatch.ElapsedMilliseconds); if (!isSuccess) { SetConsoleColor(ConsoleColor.Red); Console.WriteLine("Failed to initialize CSuperSocket ServiceEngine! Please check error log for more information!"); Console.ReadKey(); return; } _server = bootstrap.AppServers.ToList().FirstOrDefault() as Service; Console.WriteLine("Starting..."); var result = bootstrap.Start(); Console.WriteLine("监听端口:{0}", simpleCfg.Port); Console.WriteLine("-------------------------------------------------------------------"); SetConsoleColor(ConsoleColor.Green); //Console.WriteLine($"上位机唯一Id:{ConfigurationManager.AppSettings["Pid"].ToString()}"); }
static void Main(string[] args) { //var server = new TelnetServer(); //server.Setup(6001); //server.Start(); //Console.ReadKey(); var bootstrap = BootstrapFactory.CreateBootstrap(); if (!bootstrap.Initialize()) { Console.WriteLine("Initialize error"); } var result = bootstrap.Start(); if (result == StartResult.Success) { Console.WriteLine("Start completed"); } else { Console.WriteLine("Start error"); } Console.ReadKey(); bootstrap.Stop(); }
public static bool Start() { try { var configFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, LogServiceConfigFileName); IBootstrap = BootstrapFactory.CreateBootstrapFromConfigFile(configFilePath); if (!IBootstrap.Initialize()) { Console.WriteLine("日志服务初始化失败"); Logger.Error("日志服务启动失败!"); return(false); } var result = IBootstrap.Start(); if (result == StartResult.Failed) { Console.WriteLine("日志服务启动失败!"); Logger.Error("日志服务启动失败!"); return(false); } return(true); } catch (Exception ex) { Logger.Error($"启动日志Socket服务失败:{ex}"); return(false); } }
static void Main(string[] args) { var bootstrap = BootstrapFactory.CreateBootstrap(); if (!bootstrap.Initialize()) { Console.WriteLine("设置失败!"); Console.ReadKey(); return; } var result = bootstrap.Start(); if (result == StartResult.Failed) { Console.WriteLine("启动失败!"); Console.ReadKey(); return; } Console.WriteLine("服务启动成功"); Console.ReadLine(); bootstrap.Stop(); Console.WriteLine("服务关闭!"); Console.ReadLine(); }
private static log4net.ILog log = log4net.LogManager.GetLogger("SuperSocketMain");//log2.0.3->2.0.8 public static void Init() { try { Console.WriteLine("Welcome to LotServer!"); IBootstrap bootstrap = BootstrapFactory.CreateBootstrap(); if (!bootstrap.Initialize()) { Console.WriteLine("LotServer初始化失败"); Console.ReadKey(); return; } Console.WriteLine("LotServer启动中..."); var result = bootstrap.Start(); foreach (var server in bootstrap.AppServers) { if (server.State == ServerState.Running) { Console.WriteLine("- {0} 运行中", server.Name); } else { Console.WriteLine("- {0} 启动失败", server.Name); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.Read(); }
public static void Main(string[] args) { var bootstrap = BootstrapFactory.CreateBootstrap(); if (!bootstrap.Initialize()) { throw new Exception("网关服务器初始化失败"); } var result = bootstrap.Start(); if (result == StartResult.Failed) { throw new Exception("网关服务器启动失败"); } Console.WriteLine("网关服务器启动成功"); while (true) { if (Console.ReadLine() == "quit") { break; } else { Console.WriteLine(bootstrap.AppServers.First().SessionCount); } } bootstrap.Stop(); Console.WriteLine("byebye"); }
//窗体加载的时候开启监听 private void Form1_Load(object sender, EventArgs e) { log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo("Config/log4net.config")); //声明bootStrap实例 bootstrap = BootstrapFactory.CreateBootstrap(); //初始化 if (!bootstrap.Initialize()) { SetMessage("Failed to initialize!"); return; } //开启服务 var result = bootstrap.Start(); if (result == StartResult.Failed) { SetMessage("Failed to start!"); return; } else { SetMessage("服务器启动成功"); } }
static void Main(string[] args) { Console.WriteLine("Press any key to start the server!"); Console.ReadKey(); Console.WriteLine(); var bootstrap = BootstrapFactory.CreateBootstrap(); if (!bootstrap.Initialize()) { Console.WriteLine("Failed to initialize!"); Console.ReadKey(); return; } var result = bootstrap.Start(); Console.WriteLine("Start result: {0}!", result); if (result == StartResult.Failed) { Console.WriteLine("Failed to start!"); Console.ReadKey(); return; } foreach (var s in bootstrap.AppServers) { if (s is TelnetServer) { TelnetServer x = s as TelnetServer; x.NewSessionConnected += new SessionHandler <TelnetSession>(telnetServer_NewSessionConnected); x.SessionClosed += new SessionHandler <TelnetSession, CloseReason>(telnetServer_SessionClosed); } else if (s is CustomServer) { CustomServer x = s as CustomServer; x.NewSessionConnected += new SessionHandler <CustomSession>(customServer_NewSessionConnected); x.SessionClosed += new SessionHandler <CustomSession, CloseReason>(customServer_SessionClosed); } } Console.WriteLine("Press key 'q' to stop it!"); while (Console.ReadKey().KeyChar != 'q') { Console.WriteLine(); continue; } Console.WriteLine(); //Stop the appServer bootstrap.Stop(); Console.WriteLine("The server was stopped!"); Console.ReadKey(); }
static void Main(string[] args) { Console.WriteLine("Press any key to start the server!"); Console.ReadKey(); Console.WriteLine(); var bootstrap = BootstrapFactory.CreateBootstrap(); if (!bootstrap.Initialize()) { Console.WriteLine("Failed to initialize!"); Console.ReadKey(); return; } var result = bootstrap.Start(); Console.WriteLine("Start result: {0}!", result); if (result == StartResult.Failed) { Console.WriteLine("Failed to start!"); Console.ReadKey(); return; } /** * var appServer = new AMAppServer(); * if (!appServer.Setup(8080)) * { * Console.WriteLine("Failed to setup!"); * Console.ReadKey(); * return; * } * Console.WriteLine(); * if (!appServer.Start()) * { * Console.WriteLine("Failed to start!"); * Console.ReadKey(); * return; * }**/ Console.WriteLine("Press key 'q' to stop it!"); while (Console.ReadKey().KeyChar != 'q') { Console.WriteLine(); continue; } Console.WriteLine(); //Stop the appServer bootstrap.Stop(); //appServer.Stop(); Console.WriteLine("The server was stopped!"); Console.ReadKey(); }
/// <summary> /// 初始化服务 /// </summary> private void InitServer() { Bootstrap = BootstrapFactory.CreateBootstrap(); if (Bootstrap.Initialize()) { RefreshServerInfoList(); } }
static void Main(string[] args) { Console.WriteLine("{0} -> Check TempData DB status ...", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")); SQLiteHelper.CreateLocalDB("TempData"); Console.WriteLine("{0} -> Check GatewayData Table In TempData...", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")); SQLiteHelper.CreateTempDataTable("TempData"); Console.WriteLine("{0} -> Finish TempData DB and GatewayData Table Checked.", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")); //Console.WriteLine("{0} -> Press any key to start the server!", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")); //Console.ReadKey(); //Console.WriteLine(); var bootstrap = BootstrapFactory.CreateBootstrap(); if (!bootstrap.Initialize()) { Console.WriteLine("{0} -> Failed to initialize!", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")); Console.ReadKey(); return; } var result = bootstrap.Start(); Console.WriteLine("{1} -> Start result: {0}!", result, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")); if (result == StartResult.Failed) { Console.WriteLine("{0} -> Failed to start!", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")); Console.ReadKey(); return; } while (true) { Thread.Sleep(1); } //Console.WriteLine("Press key 'q' to stop it!"); //while (Console.ReadKey().KeyChar != 'q') //{ // Console.WriteLine(); // continue; //} //Console.WriteLine(); //Stop the appServer //bootstrap.Stop(); //Console.WriteLine("{0} -> The server was stopped!", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")); //Console.ReadKey(); }
static void RunAsConsole() { IBootstrap bootstrap = BootstrapFactory.CreateBootstrap(); if (!bootstrap.Initialize()) { Console.WriteLine("Failed to initialize SuperSocket server! Please check error log for more information!"); return; } var result = bootstrap.Start(); foreach (var server in bootstrap.AppServers) { if (server.IsRunning) { Console.WriteLine("- {0} has been started", server.Name); } else { Console.WriteLine("- {0} failed to start", server.Name); } } switch (result) { case (StartResult.None): Console.WriteLine("No server is configured, please check you configuration!"); break; case (StartResult.Success): Console.WriteLine("The server engine has been started!"); break; case (StartResult.Failed): Console.WriteLine("Failed to start the server engine! Please check error log for more information!"); break; case (StartResult.PartialSuccess): Console.WriteLine("Some server instances were started successfully, but the others failed to start! Please check error log for more information!"); break; } Console.WriteLine("Press key 'q' to stop the server engine."); while (Console.ReadKey().Key != ConsoleKey.Q) { Console.WriteLine(); continue; } bootstrap.Stop(); Console.WriteLine(); Console.WriteLine("The server engine has been stopped!"); }
public ServiceManager() { m_Bootstrap = BootstrapFactory.CreateBootstrap(); if (!m_Bootstrap.Initialize()) { LoggerManager.Log(ELoggerType.Error, "SuperSocket 初始化失败"); return; } }
public MyBootstrap() { _bootstrap = BootstrapFactory.CreateBootstrap(); _bootstrap.Initialize(); _bootstrap.Start(); //if (_bootstrap.Initialize()) TraceLog.WriteLine("Initialize"); //else { TraceLog.WriteLine("Initialize failed"); return; } //var result = _bootstrap.Start(); //TraceLog.WriteLine("Start " + result.ToString()); }
static void Main(string[] args) { Console.WriteLine("请按任何键启动区域指挥中心平台!"); Console.ReadKey(); Console.WriteLine(); var bootstrap = BootstrapFactory.CreateBootstrap(); if (!bootstrap.Initialize()) { Console.WriteLine("初始化失败!"); Console.ReadKey(); return; } #region 加载基础设备或通信模块 try { SerialCOMManager.CreateInstance(); Console.WriteLine("串口设备初始化完成"); HikSdkManager hiksdk = HikSdkManager.CreateInstance(); Console.WriteLine("海康SDK初始化完成"); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.ReadKey(); return; } #endregion var result = bootstrap.Start(); Console.WriteLine("服务正在启动: {0}!", result); if (result == StartResult.Failed) { Console.WriteLine("服务启动失败!"); Console.ReadKey(); return; } Console.WriteLine("服务启动成功,请按'q'停止服务!"); while (Console.ReadKey().KeyChar != 'q') { Console.WriteLine(); continue; } //停止服务 // appServer.Stop(); bootstrap.Stop(); Console.WriteLine("服务已停止!"); Console.ReadKey(); }
/// <summary> /// 初始化服务器 /// </summary> private bool SetupAppServer() { m_Bootstrap = BootstrapFactory.CreateBootstrap(); if (!m_Bootstrap.Initialize()) { txtMsg.AppendRichText($"{DateTime.Now}>> 初始化服务器配置文件失败,请检查.{Environment.NewLine}", new Font("微软雅黑", 9), Color.Crimson); return(false); } txtMsg.AppendRichText($"{DateTime.Now}>> 初始化服务器配置成功.{Environment.NewLine}", new Font("微软雅黑", 9), Color.FromArgb(2, 79, 142)); return(true); }
private void btnStartStop_Click(object sender, EventArgs e) { if (btnStartStop.Text == "启动服务") { bootstrap = BootstrapFactory.CreateBootstrap(); if (!bootstrap.Initialize()) { ServiceStatus = false; MessageBox.Show("Failed to initialize!"); return; } else { StartResult result = bootstrap.Start(); if (result == StartResult.Failed) { ServiceStatus = false; } else if (result == StartResult.Success) { var transferServer = bootstrap.GetServerByName("TransferServer") as TransferServer; transferServer.NewSessionConnected += transferServer_NewSessionConnected; transferServer.SessionClosed += transferServer_SessionClosed; var userServer = bootstrap.GetServerByName("UserServer") as UserServer; userServer.UserJoin += userServer_UserJoin; userServer.UserLeave += userServer_UserLeave; userServer.SendToServer += userServer_UserSendToServer; userServer.UserWhisper += userServer_UserWhisper; userServer.Broadcast += userServer_UserBroadcast; ServiceStatus = true; } else { //MessageBox.Show(string.Format("Start result: {0}!", result)); } this.lblStatus.Text = result.ToString(); } } else { bootstrap.Stop(); ServiceStatus = false; this.lblStatus.Text = "The server was stopped!"; } if (ServiceStatus) { btnStartStop.Text = "停止服务"; } else { btnStartStop.Text = "启动服务"; } }
public BusServer() { // Load the server configuration from app.config // This is needed to ensure the server is only // broadcasting and accepting connectiosn on 127.0.0.1 // for security. var bootstrap = BootstrapFactory.CreateBootstrap(); bootstrap.Initialize(); bootstrap.Start(); Socket = bootstrap.AppServers.FirstOrDefault() as WebSocketServer; }
protected IConfigurationSource CreateBootstrap(string configFile, out IBootstrap newBootstrap) { var fileMap = new ExeConfigurationFileMap(); var filePath = Path.Combine(@"Config", configFile); fileMap.ExeConfigFilename = filePath; var config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None); var configSource = config.GetSection("superSocket") as IConfigurationSource; newBootstrap = BootstrapFactory.CreateBootstrap(configSource); return(configSource); }
/// <summary> /// 初始化Socket服务 /// <code> /// SocketServiceContainer.Create(CurrentAddinConfiguration); /// </code> /// </summary> /// <param name="currentAddinConfig"></param> public static void Create(System.Configuration.Configuration currentAddinConfig) { IConfigurationSource configSource = currentAddinConfig.GetSection(SocketSection.SectionName) as IConfigurationSource; if (configSource == null) { return; } IBootstrap bootstrap = BootstrapFactory.CreateBootstrap(configSource); bootstrap.Initialize(new Log4NetLogFactory()); StartResult result = bootstrap.Start(); }
static void Main(string[] args) { Console.WriteLine("Press any key to start the server!"); Console.ReadKey(); Console.WriteLine(); IBootstrap bootstrap = null; try { bootstrap = BootstrapFactory.CreateBootstrap(); } catch (System.Configuration.ConfigurationErrorsException ex) { Console.WriteLine(ex.Message); Environment.Exit(-1); } if (!bootstrap.Initialize()) { Console.WriteLine("Failed to initialize!"); Console.ReadKey(); return; } var result = bootstrap.Start(); Console.WriteLine("Start result: {0}!", result); if (result == StartResult.Failed) { Console.WriteLine("Failed to start!"); Console.ReadKey(); return; } Console.WriteLine("Press key 'q' to stop it!"); while (Console.ReadKey().KeyChar != 'q') { Console.WriteLine(); continue; } Console.WriteLine(); //Stop the appServer bootstrap.Stop(); Console.WriteLine("The server was stopped!"); Console.ReadKey(); }
static void Main(string[] args) { Console.WriteLine("Press any key to start server!"); Console.ReadKey(); Console.WriteLine(); Console.WriteLine("Starting..."); var bootstrap = BootstrapFactory.CreateBootstrap(); if (!bootstrap.Initialize()) { Console.WriteLine("Failed to initialize SuperSocket server! Please check error log for more information!"); return; } var result = bootstrap.Start(); switch (result) { case (StartResult.None): Console.WriteLine("No server is configured, please check you configuration!"); break; case (StartResult.Success): Console.WriteLine("The server has been started!"); break; case (StartResult.Failed): Console.WriteLine("Failed to start SuperSocket server! Please check error log for more information!"); break; case (StartResult.PartialSuccess): Console.WriteLine("Some server instances were started successfully, but the others failed to start! Please check error log for more information!"); break; } Console.WriteLine("Press key 'q' to stop the server."); while (Console.ReadKey().Key != ConsoleKey.Q) { Console.WriteLine(); continue; } bootstrap.Stop(); Console.WriteLine(); Console.WriteLine("The server has been stopped!"); }