How a Photon Application do a stop request?

Options
dsilvavinicius
edited September 2013 in Photon Server
I want to stop my application if an Exception occurs at the Setup() function. The problem is that ApplicationBase does not seem to have such an API. Thus, I have supposed that unhandled Exceptions at Setup() would implicit stop the server, but my tests showed the opposite. That's what I want:

[code2=csharp]public sealed class MatchServerApplication : ApplicationBase
{
//Other members
// ...
//

protected override void Setup() {
try {
//Do init
}
catch (Exception e){
//Whatever I should call to stop the Application
}

}
}[/code2]

Any ideas?

Comments

  • Problem solved. Just needed to throw a SystemException to make the server stop.
    [code2=csharp]public sealed class MatchServerApplication : ApplicationBase
    {
    //Other members
    // ...
    //

    protected override void Setup() {
    try {
    //Do init
    }
    catch (Exception e){
    throw new SystemException("Message");
    }

    }
    }[/code2]
  • Hi,

    we don't have a "built in" method to stop Photon from inside the code, but if an application does not start successfully (= because an exception is thrown in Setup()), Photon fails to start.

    We think that it's in general better to stop Photon than let it run with an application that was not initialized correctly.

    So your approach to throw any exception (or just re-throw the original one) is fine.