Fields Summary |
---|
public static final int | DISCONNECTEDConnection state that indicates the connection is not connected yet. |
public static final int | LOGGING_INConnection state that indicates the user is logging into the server. |
public static final int | LOGGED_INConnection state that indicates the user has logged into the server. |
public static final int | LOGGING_OUTConnection state that indicates the user is logging out the server. |
public static final int | SUSPENDINGConnection state that indicate the connection is suspending. |
public static final int | SUSPENDEDConnection state that indicate the connection has been suspended. |
public static final int | CAPABILITY_GROUP_CHATThe capability of supporting group chat. |
public static final int | CAPABILITY_SESSION_REESTABLISHMENTThe capability of supporting session re-establishment. |
protected int | mStateThe current state of the connection. |
protected CopyOnWriteArrayList | mConnectionListeners |
protected Presence | mUserPresence |
Methods Summary |
---|
public void | addConnectionListener(ConnectionListener listener)
if (listener != null) {
mConnectionListeners.add(listener);
}
|
protected abstract void | doUpdateUserPresenceAsync(Presence presence)
|
public abstract int | getCapability()Gets bit-or of capabilities supported by the underlying protocol. Valid
capability bits are: {@value #CAPABILITY_GROUP_CHAT},
{@value #CAPABILITY_SESSION_REESTABLISHMENT}
|
public abstract ChatGroupManager | getChatGroupManager()Gets the instance of ChatGroupManager for the connection.
|
public abstract ChatSessionManager | getChatSessionManager()Gets the instance of ChatSessionManager for the connection.
|
public abstract ContactListManager | getContactListManager()Gets the instance of ContactListManager for the connection.
|
public abstract Contact | getLoginUser()
|
public java.lang.String | getLoginUserName()
Contact loginUser = getLoginUser();
return loginUser == null ? null : loginUser.getName();
|
public abstract java.util.HashMap | getSessionContext()Gets the cookie of the current session. The client could store the
context and use it to re-establish the session by
{@link #reestablishSessionAsync(HashMap)}}. The stored context MUST be
removed upon the connection logout/disconnect.
|
public int | getState()Tells the current state of the connection.
return mState;
|
public abstract int[] | getSupportedPresenceStatus()
|
public Presence | getUserPresence()
if (mState == SUSPENDING || mState == SUSPENDED) {
return new Presence();
}
if (mState != LOGGED_IN) {
// In most cases we have a valid mUserPresence instance also
// in the LOGGING_OUT state. However there is one exception:
// if logout() is called before login finishes, the state may
// jump from LOGGING_IN directly to LOGGING_OUT, skipping the
// LOGGED_IN state. In this case we won't have a valid Presence
// in the LOGGING_OUT state.
return null;
}
return new Presence(mUserPresence);
|
public abstract void | loginAsync(LoginInfo loginInfo)Log in to the IM server.
|
public abstract void | logoutAsync()Log out from the IM server.
|
public void | networkTypeChanged()Tells the engine that the network type has changed, e.g. switch from gprs
to wifi. The engine should drop all the network connections created before
because they are not available anymore.
The engine might also need to redo authentication on the new network depending
on the underlying protocol.
|
protected void | notifyUpdateUserPresenceError(ImErrorInfo error)
for (ConnectionListener listener : mConnectionListeners) {
listener.onUpdatePresenceError(error);
}
|
protected void | notifyUserPresenceUpdated()
for (ConnectionListener listener : mConnectionListeners) {
listener.onUserPresenceUpdated();
}
|
public abstract void | reestablishSessionAsync(java.util.HashMap sessionContext)Re-establish previous session using the session context persisted by the
client. Only sessions that were dropped unexpectedly(e.g. power loss, crash,
etc) can be re-established using the stored session context. If the
session was terminated normally by either user logging out or server
initiated disconnection, it can't be re-established again therefore the
stored context should be removed by the client.
The client can query if session re-establishment is supported through
{@link #getCapability()}.
|
public void | removeConnectionListener(ConnectionListener listener)
mConnectionListeners.remove(listener);
|
protected void | setState(int state, ImErrorInfo error)Sets the state of the connection.
if(state < DISCONNECTED || state > SUSPENDED){
throw new IllegalArgumentException("Invalid state: " + state);
}
if(mState != state){
mState = state;
for(ConnectionListener listener : mConnectionListeners){
listener.onStateChanged(state, error);
}
}
|
public abstract void | suspend()Suspend connection with the IM server.
|
public void | updateUserPresenceAsync(Presence newPresence)
if (mState != LOGGED_IN) {
throw new ImException(ImErrorInfo.NOT_LOGGED_IN, "NOT logged in");
}
doUpdateUserPresenceAsync(newPresence);
|