Add SuperSocket startup code to Windows Azure project of WorkRole

Like other SuperSocket program, startup code also have to write the entrance to the program, such as the WorkRole OnStart Windows Azure project () method:

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

}

Guess you like

Origin www.cnblogs.com/fanweisheng/p/11127207.html