Creates the registration for this application and starts the connection. An ApplicationTimeoutException is thrown if the method does not succeed within the number of seconds specified by the timeout.
If a callback handler is registered and network connectivity is available, the sequence of callbacks as a result of calling RegisterApplication is:
OnRegistrationStatusChanged(RegistrationStatus.REGISTERING, 0, "") OnConnectionStatusChanged(ConnectionStatus.CONNECTING, 0, "") OnConnectionStatusChanged(ConnectionStatus.CONNECTED, 0, "") OnRegistrationStatusChanged(RegistrationStatus.REGISTERED, 0, "")
When the connectionStatus of CONNECTED has been reached and the application's applicationSettings have been received from the server, the application is now in a suitable state for database subscriptions and/or synchronization. If a callback handler is registered and network connectivity is unavailable, the sequence of callbacks as a result of calling registerApplication is:
OnRegistrationStatusChanged(RegistrationStatus.REGISTERING, 0, "") OnRegistrationStatusChanged(RegistrationStatus.REGISTRATION_ERROR, code, message)
In such a case, the registration process has permanently failed and will not continue in the background. If a callback handler is registered and network connectivity is available for the start of registration but becomes unavailable before the connection is established, the sequence of callbacks as a result of calling registerApplication is:
OnRegistrationStatusChanged(RegistrationStatus.REGISTERING, 0, "") OnConnectionStatusChanged(ConnectionStatus.CONNECTING, 0, "") OnConnectionStatusChanged(ConnectionStatus.CONNECTION_ERROR, code, message)
In such a case, the registration process has temporarily failed and will continue in the background when network connectivity is restored.
public void RegisterApplication(int timeout)
app.RegisterApplication(60);
You must set up the ConnectionProperties and ApplicationIdentifier before you can invoke registerApplication.
Application app = Application.GetInstance(); // set Application ID - need to match as the server side Application ID app.ApplicationIdentifier = "MyPackage"; app.ApplicationCallback = new MyApplicationCallbackHandler(); ConnectionProperties props = app.ConnectionProperties; props.ServerName = "supserver.mycompany.com"; props.PortNumber = 5001; LoginCredentials loginCred = new LoginCredentials("supAdmin", "supPwd"); props.LoginCredentials = loginCred; MyPackageDB.SetApplication(app); if (app.RegistrationStatus != RegistrationStatus.REGISTERED) { app.RegisterApplication(); }