添加SuperSocket的启动代码到 Windows Azure 的 WorkRole 项目

Posted fanweisheng

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了添加SuperSocket的启动代码到 Windows Azure 的 WorkRole 项目相关的知识,希望对你有一定的参考价值。

与其它SuperSocket程序相同,启动代码同样也要写到程序的入口处,如 Windows Azure 的 WorkRole 项目的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.

 

    m_Bootstrap = BootstrapFactory.CreateBootstrap();

 

    if (!m_Bootstrap.Initialize())

   

        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();

以上是关于添加SuperSocket的启动代码到 Windows Azure 的 WorkRole 项目的主要内容,如果未能解决你的问题,请参考以下文章

SuperSocket 扩展你的 Logger

SuperSocket入门- 探索AppServerAppSession,Conmmand和App.config

C#里发现SuperSocket库不能发现命令的原因

SuperSocket基础一

SuperSocket调试工具

SuperSocket 日志接口