interface IO2GSessionStatus

Brief

The interface provides method signatures to process notifications about session status changes and login failures.

Details

The interface must be implemented by the application in order to process the status change of the session object.

When a user tries to login, the session status changes to to Connecting.

If a login failed, the status changes to Disconnected and the server returns an error message explaining why the login has failed. If you want to capture what has gone wrong, use the onLoginFailed method of the interface.

If a login was successful, the session status changes to Connected. If you want to capture and process every status change of the session object, use the onSessionStatusChanged method of the interface. For a complete list of the session statuses, please see O2GSessionStatusCode. For a detailed explanation of the session statuses, refer to the Session Statuses section.

If you want to use the methods of the IO2GSessionStatus interface, you must create a class that implements the interface. For example,
public class SessionStatusListener: IO2GSessionStatus { }

An instance of the class implementing the IO2GSessionStatus interface must be subscribed to the session object before calling the O2GSession.login method. It is accomplished by calling the O2GSession.subscribeSessionStatus method. For example,

mSession = O2GTransport.createSession();
SessionStatusListener statusListener = new SessionStatusListener(mSession, mDBName, mPin);
mSession.subscribeSessionStatus(statusListener);

The subscribed instance must be unsubscribed from the session object after calling the O2GSession.logout method, but before calling the O2GSession.Dispose method. It is accomplished by calling the O2GSession.unsubscribeSessionStatus method. For example,

mSession.logout();
mSession.unsubscribeSessionStatus(statusListener);
mSession.dispose();

For the interface implementation details, see the example below: Example

Process notifications about session status changes and a login failure [show]

Example

Processing a login failure [hide]

     // Create a session, subscribe to session listener, login
     mSession = O2GTransport.createSession();
     SessionStatusListener statusListener = new SessionStatusListener(mSession, mDBName, mPin);
     mSession.subscribeSessionStatus(statusListener);
     mSession.login(mUserID, mPassword, mURL, mConnection);
     while (!statusListener.isConnected() && !statusListener.hasError()) {
          Thread.Sleep(50);
     }
 
    // Implementation of IO2GSessionStatus interface public method onLoginFailed
    public void onLoginFailed(String error) {
        Console.WriteLine("Login error: " + error);
        mError = true;
    }

The type defined in the fxcore2.dll assembly. The namespace is fxcore2.

Public Methods

onLoginFailed

Processes a notification about a login failure.

onSessionStatusChanged

Processes notifications about session status changes.

back