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


C# IBootstrap.Start方法代码示例

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


在下文中一共展示了IBootstrap.Start方法的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: StartSuperWebSocketByProgramming

        public void StartSuperWebSocketByProgramming()
        {
            var socketServer = new WebSocketServer();

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

            socketServer.Setup(port);

            m_Bootstrap = new DefaultBootstrap(new RootConfig(), new IWorkItem[] { socketServer });

            m_Bootstrap.Start();
        }
开发者ID:smeshlink,项目名称:CoAP.Proxy,代码行数:14,代码来源:WebSocketService.cs

示例4: 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

示例5: 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

示例6: TestActiveConnect

        public void TestActiveConnect()
        {
            StartBootstrap(DefaultServerConfig);

            IBootstrap activeServerBootstrap;
            var activeTargetServerConfig = CreateBootstrap("ActiveConnectServer.config", out activeServerBootstrap);

            Assert.IsTrue(activeServerBootstrap.Initialize());

            var serverConfig = activeTargetServerConfig.Servers.FirstOrDefault();
            var serverAddress = new IPEndPoint(IPAddress.Parse("127.0.0.1"), serverConfig.Port);

            m_ActiveServerBootstrap = AppDomain.CurrentDomain.GetData("Bootstrap") as IBootstrap;

            Assert.AreEqual(StartResult.Success, m_ActiveServerBootstrap.Start());

            var appServer = BootStrap.AppServers.FirstOrDefault() as TestServer;

            var task = appServer.ActiveConnectRemote(serverAddress);

            if (!task.Wait(5000))
            {
                Assert.Fail("Active connect the server timeout");
            }

            Assert.AreEqual(TaskStatus.RanToCompletion, task.Status);

            Assert.AreEqual(true, task.Result.Result);
            Assert.IsNotNull(task.Result.Session);

            Assert.AreEqual(1, m_ActiveServerBootstrap.AppServers.FirstOrDefault().SessionCount);

            var session = task.Result.Session as TestSession;

            var rd = new Random();
            var a = rd.Next(1, 1000);
            var b = rd.Next(1, 1000);
            session.Send("ADDR " + a + " " + b);
            Thread.Sleep(500);

            Assert.AreEqual((a + b).ToString(), RESU.Result);
        }
开发者ID:00jiajia,项目名称:SuperSocket,代码行数:42,代码来源:TcpSocketServerTest.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: 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

示例9: 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

示例10: StartSuperWebSocketByProgramming

        void StartSuperWebSocketByProgramming()
        {
            var rootConfig = new RootConfig();

            var socketServer = new WebSocketServer();

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

            socketServer.Setup(rootConfig,
                new ServerConfig
                    {
                        Name = "SuperWebSocket",
                        Ip = "Any",
                        Port = 2011,
                        Mode = SocketMode.Tcp
                    });

            var secureSocketServer = new WebSocketServer();
            secureSocketServer.NewSessionConnected += secureSocketServer_NewSessionConnected;
            secureSocketServer.SessionClosed += secureSocketServer_SessionClosed;

            secureSocketServer.Setup(rootConfig, 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"
                        }
                    });

            m_Bootstrap = new DefaultBootstrap(new RootConfig(), new IWorkItem[] { socketServer, secureSocketServer });

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

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

示例11: TestActiveConnect

        public void TestActiveConnect()
        {
            StartBootstrap(DefaultServerConfig);

            IBootstrap activeServerBootstrap;
            var activeTargetServerConfig = CreateBootstrap("ActiveConnectServer.config", out activeServerBootstrap);

            Assert.IsTrue(activeServerBootstrap.Initialize());

            var serverConfig = activeTargetServerConfig.Servers.FirstOrDefault();
            var serverAddress = new IPEndPoint(IPAddress.Parse("127.0.0.1"), serverConfig.Port);

            m_ActiveServerBootstrap = activeServerBootstrap;

            Assert.AreEqual(StartResult.Success, m_ActiveServerBootstrap.Start());

            var appServer = BootStrap.AppServers.FirstOrDefault() as TestServer;

            var task = appServer.ActiveConnectRemote(serverAddress);

            if (!task.Wait(5000))
            {
                Assert.Fail("Active connect the server timeout");
            }

            Assert.AreEqual(TaskStatus.RanToCompletion, task.Status);

            Assert.AreEqual(true, task.Result.Result);
            Assert.IsNotNull(task.Result.Session);

            var remoteServer = m_ActiveServerBootstrap.AppServers.FirstOrDefault() as TestServer;

            Thread.Sleep(100);

            Assert.AreEqual(1, appServer.SessionCount);
            Assert.AreEqual(1, remoteServer.SessionCount);

            var session = task.Result.Session as TestSession;

            var rd = new Random();
            var a = rd.Next(1, 1000);
            var b = rd.Next(1, 1000);
            session.Send("ADDR " + a + " " + b);
            Thread.Sleep(500);

            Assert.AreEqual((a + b).ToString(), RESU.Result);

            var resetEvent = new AutoResetEvent(false);

            //Reconnect
            session.SocketSession.Closed += (s, c) =>
                {
                    resetEvent.WaitOne();
                    Thread.Sleep(5000);
                    var t = appServer.ActiveConnectRemote(serverAddress);
                    t.ContinueWith((x) =>
                        {
                            if (x.Exception != null)
                                Console.WriteLine(x.Exception.InnerException.Message);

                            resetEvent.Set();
                        });
                };

            foreach (var s in remoteServer.GetAllSessions())
            {
                s.Close();
            }

            Thread.Sleep(500);

            Assert.AreEqual(0, appServer.SessionCount);
            Assert.AreEqual(0, remoteServer.SessionCount);

            resetEvent.Set();
            Thread.Sleep(500);
            resetEvent.WaitOne();

            Thread.Sleep(500);

            Assert.AreEqual(1, appServer.SessionCount);
            Assert.AreEqual(1, remoteServer.SessionCount);

        }
开发者ID:RocChing,项目名称:SuperSocket,代码行数:84,代码来源:TcpSocketServerTest.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.Start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。