本文整理汇总了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());
}
示例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();
}
示例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();
}
示例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());
}
示例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());
}
示例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();
}
示例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();
}
示例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());
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}