当前位置: 首页>>代码示例>>C#>>正文


C# IBootstrap.Initialize方法代码示例

本文整理汇总了C#中IBootstrap.Initialize方法的典型用法代码示例。如果您正苦于以下问题:C# IBootstrap.Initialize方法的具体用法?C# IBootstrap.Initialize怎么用?C# IBootstrap.Initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IBootstrap的用法示例。


在下文中一共展示了IBootstrap.Initialize方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Setup

 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());
 }
开发者ID:RocChing,项目名称:SuperSocket,代码行数:7,代码来源:UnitTest.cs

示例2: Start

 public static void Start()
 {
     bootstrap = BootstrapFactory.CreateBootstrap();
     if (!bootstrap.Initialize())
     {
         Console.WriteLine("Failed to initialize!");
         return;
     }
     ouSrv = (OpcUserServer)bootstrap.AppServers.First();
     ouSrv.NewSessionConnected += new SessionHandler<OpcUserSession>(SessionConnected);
     ouSrv.SessionClosed += new SessionHandler<OpcUserSession, CloseReason>(SessionClosed);
     StartResult result = bootstrap.Start();
 }
开发者ID:TscCai,项目名称:sis,代码行数:13,代码来源:ServerManager.cs

示例3: OnStart

        public override bool OnStart()
        {
            Trace.TraceInformation("WorkerRole1 is starting");
            NewRelic.Api.Agent.NewRelic.SetTransactionName("Worker", "OnStart"); var watch = Stopwatch.StartNew();

            // Set the maximum number of concurrent connections 
            ServicePointManager.DefaultConnectionLimit = 200;

            // For information on handling configuration changes
            // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

            m_Bootstrap = BootstrapFactory.CreateBootstrap();

            var endpoints = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints.ToDictionary
                (p => p.Key, p => p.Value.IPEndpoint);
            if (!m_Bootstrap.Initialize(endpoints))
            {
                Trace.WriteLine("Failed to initialize SuperSocket!", "Error");
                NewRelic.Api.Agent.NewRelic.RecordResponseTimeMetric("OnStart", watch.ElapsedMilliseconds);
                return false;
            }

            var result = m_Bootstrap.Start();

            switch (result)
            {
                case (StartResult.None):
                    Trace.WriteLine("No server is configured, please check you configuration!");
                    NewRelic.Api.Agent.NewRelic.RecordResponseTimeMetric("OnStart", watch.ElapsedMilliseconds);
                    return false;

                case (StartResult.Success):
                    Trace.WriteLine("The server has been started!");
                    break;

                case (StartResult.Failed):
                    Trace.WriteLine("Failed to start SuperSocket server! Please check error log for more information!");
                    NewRelic.Api.Agent.NewRelic.RecordResponseTimeMetric("OnStart", watch.ElapsedMilliseconds);
                    return false;

                case (StartResult.PartialSuccess):
                    Trace.WriteLine("Some server instances were started successfully, but the others failed to start! Please check error log for more information!");
                    break;
            }

            Trace.TraceInformation("WorkerRole1 has started");
            NewRelic.Api.Agent.NewRelic.RecordResponseTimeMetric("OnStart", watch.ElapsedMilliseconds);

            return base.OnStart();
        }
开发者ID:lupyuen,项目名称:AzureIoTService,代码行数:50,代码来源:WorkerRole.cs

示例4: Setup

        public virtual void Setup()
        {
            m_Bootstrap = new DefaultBootstrap();

            m_WebSocketServer = new WebSocketServer(new BasicSubProtocol("Basic", new List<Assembly> { this.GetType().Assembly }));
            m_WebSocketServer.NewDataReceived += new SessionEventHandler<WebSocketSession, byte[]>(m_WebSocketServer_NewDataReceived);
            m_Bootstrap.Initialize(new RootConfig { DisablePerformanceDataCollector = true }, new IAppServer[] { m_WebSocketServer }, new IServerConfig[] { new ServerConfig
                {
                    Port = 2012,
                    Ip = "Any",
                    MaxConnectionNumber = 100,
                    Mode = SocketMode.Tcp,
                    Name = "SuperWebSocket Server"
                }}, new ConsoleLogFactory());
        }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:15,代码来源:WebSocketClientTest.cs

示例5: Setup

        public void Setup()
        {
            m_Bootstrap = new DefaultBootstrap();

            m_Config = new ServerConfig
            {
                Port = 555,
                Ip = "Any",
                MaxConnectionNumber = 10,
                Mode = SocketMode.Tcp,
                Name = "GPSServer"
            };

            m_Server = new GPSServer();
            m_Bootstrap.Initialize(new RootConfig(), new IAppServer[] { m_Server }, new IServerConfig[] { m_Config }, new ConsoleLogFactory());
        }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:16,代码来源:GPSServerTest.cs

示例6: StartSuperWebSocketByConfig

        void StartSuperWebSocketByConfig()
        {
            m_Bootstrap = BootstrapFactory.CreateBootstrap();

            if (!m_Bootstrap.Initialize())
                return;

            var socketServer = m_Bootstrap.AppServers.FirstOrDefault(s => s.Name.Equals("SuperWebSocket")) as WebSocketServer;

            socketServer.NewMessageReceived += new SessionHandler<WebSocketSession, string>(socketServer_NewMessageReceived);
            socketServer.NewSessionConnected += socketServer_NewSessionConnected;
            socketServer.SessionClosed += socketServer_SessionClosed;

            m_WebSocketServer = socketServer;

            m_Bootstrap.Start();
        }
开发者ID:2594636985,项目名称:SuperWebSocket,代码行数:17,代码来源:Global.asax.cs

示例7: OnStart

        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 100;

            // For information on handling configuration changes
            // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

            var serverConfig = ConfigurationManager.GetSection("socketServer") as SocketServiceConfig;

            m_Bootstrap = BootstrapFactory.CreateBootstrap(serverConfig);

            if (!m_Bootstrap.Initialize(ResolveServerConfig))
            {
                Trace.WriteLine("Failed to initialize SuperSocket!", "Error");
                return false;
            }

            var result = m_Bootstrap.Start();

            switch (result)
            {
                case (StartResult.None):
                    Trace.WriteLine("No server is configured, please check you configuration!");
                    return false;

                case (StartResult.Success):
                    Trace.WriteLine("The server has been started!");
                    break;

                case (StartResult.Failed):
                    Trace.WriteLine("Failed to start SuperSocket server! Please check error log for more information!");
                    return false;

                case (StartResult.PartialSuccess):
                    Trace.WriteLine("Some server instances were started successfully, but the others failed to start! Please check error log for more information!");
                    break;
            }

            return base.OnStart();
        }
开发者ID:wulinfeng2008,项目名称:SuperSocket,代码行数:41,代码来源:WorkerRole.cs

示例8: Setup

        public virtual void Setup()
        {
            if (LogFactoryProvider.LogFactory == null)
                LogFactoryProvider.Initialize(new ConsoleLogFactory());

            m_Bootstrap = new DefaultBootstrap();

            m_WebSocketServer = new WebSocketServer();

            m_WebSocketServer.NewMessageReceived += new SessionEventHandler<WebSocketSession, string>(m_WebSocketServer_NewMessageReceived);
            m_WebSocketServer.NewSessionConnected += m_WebSocketServer_NewSessionConnected;
            m_WebSocketServer.SessionClosed += m_WebSocketServer_SessionClosed;

            m_Bootstrap.Initialize(new RootConfig { DisablePerformanceDataCollector = true }, new IAppServer[] { m_WebSocketServer }, new IServerConfig[] { new ServerConfig
                {
                    Port = 2012,
                    Ip = "Any",
                    MaxConnectionNumber = 100,
                    Mode = SocketMode.Tcp,
                    Name = "SuperWebSocket Server"
                }}, new ConsoleLogFactory());
        }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:22,代码来源:WebSocketTest.cs

示例9: OnStart

        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections 
            ServicePointManager.DefaultConnectionLimit = 12;

            m_Bootstrap = BootstrapFactory.CreateBootstrap();

            if (!m_Bootstrap.Initialize(RoleEnvironment.CurrentRoleInstance.InstanceEndpoints.ToDictionary(
                p => p.Key,
                p => p.Value.IPEndpoint)))
            {
                Trace.WriteLine("Failed to initialize SuperWebSocket!", "Error");
                return false;
            }

            var result = m_Bootstrap.Start();

            switch (result)
            {
                case (StartResult.None):
                    Trace.WriteLine("No server is configured, please check you configuration!");
                    return false;

                case (StartResult.Success):
                    Trace.WriteLine("The server has been started!");
                    break;

                case (StartResult.Failed):
                    Trace.WriteLine("Failed to start SuperWebSocket server! Please check error log for more information!");
                    return false;

                case (StartResult.PartialSuccess):
                    Trace.WriteLine("Some server instances were started successfully, but the others failed to start! Please check error log for more information!");
                    break;
            }

            return base.OnStart();
        }
开发者ID:2594636985,项目名称:SuperWebSocket,代码行数:38,代码来源:WorkerRole.cs

示例10: StartSuperWebSocketByConfig

        void StartSuperWebSocketByConfig()
        {
            m_Bootstrap = new DefaultBootstrap();

            var serverConfig = ConfigurationManager.GetSection("socketServer") as SocketServiceConfig;
            if (!m_Bootstrap.Initialize(serverConfig))
                return;

            var socketServer = m_Bootstrap.AppServers.FirstOrDefault(s => s.Name.Equals("SuperWebSocket")) as WebSocketServer;
            var secureSocketServer = m_Bootstrap.AppServers.FirstOrDefault(s => s.Name.Equals("SecureSuperWebSocket")) as WebSocketServer;

            Application["WebSocketPort"] = socketServer.Config.Port;
            Application["SecureWebSocketPort"] = secureSocketServer.Config.Port;

            socketServer.NewMessageReceived += new SessionEventHandler<WebSocketSession, string>(socketServer_NewMessageReceived);
            socketServer.NewSessionConnected += socketServer_NewSessionConnected;
            socketServer.SessionClosed += socketServer_SessionClosed;

            secureSocketServer.NewSessionConnected += secureSocketServer_NewSessionConnected;
            secureSocketServer.SessionClosed += secureSocketServer_SessionClosed;

            m_Bootstrap.Start();
        }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:23,代码来源:Global.asax.cs

示例11: StartSuperWebSocketByProgramming

        void StartSuperWebSocketByProgramming()
        {
            m_Bootstrap = new DefaultBootstrap();

            var socketServer = new WebSocketServer();

            socketServer.NewMessageReceived += new SessionEventHandler<WebSocketSession, string>(socketServer_NewMessageReceived);
            socketServer.NewSessionConnected += socketServer_NewSessionConnected;
            socketServer.SessionClosed += socketServer_SessionClosed;

            var secureSocketServer = new WebSocketServer();

            m_Bootstrap.Initialize(new RootConfig(), new IAppServer[] { socketServer, secureSocketServer },
                new IServerConfig[]
                {
                    new ServerConfig
                    {
                        Name = "SuperWebSocket",
                        Ip = "Any",
                        Port = 2011,
                        Mode = SocketMode.Tcp
                    },
                    new ServerConfig
                    {
                        Name = "SecureSuperWebSocket",
                        Ip = "Any",
                        Port = 2012,
                        Mode = SocketMode.Tcp,
                        Security = "tls",
                        Certificate = new SuperSocket.SocketBase.Config.CertificateConfig
                        {
                            FilePath = Server.MapPath("~/localhost.pfx"),
                            Password = "supersocket",
                            IsEnabled = true
                        }
                    }
                });

            secureSocketServer.NewSessionConnected += secureSocketServer_NewSessionConnected;
            secureSocketServer.SessionClosed += secureSocketServer_SessionClosed;

            Application["WebSocketPort"] = socketServer.Config.Port;
            Application["SecureWebSocketPort"] = secureSocketServer.Config.Port;

            m_Bootstrap.Start();
        }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:46,代码来源:Global.asax.cs

示例12: SetupBootstrap

        private IConfigurationSource SetupBootstrap(string configFile)
        {
            var fileMap = new ExeConfigurationFileMap();
            fileMap.ExeConfigFilename = Path.Combine(@"Config", configFile);

            var config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
            var configSource = config.GetSection("socketServer") as IConfigurationSource;

            m_BootStrap = BootstrapFactory.CreateBootstrap(configSource);

            Assert.IsTrue(m_BootStrap.Initialize());

            var result = m_BootStrap.Start();

            Assert.AreEqual(StartResult.Success, result);

            return configSource;
        }
开发者ID:wulinfeng2008,项目名称:SuperSocket,代码行数:18,代码来源:BootstrapTest.cs


注:本文中的IBootstrap.Initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。