public class QBChatService extends BaseService
Modifier and Type | Class and Description |
---|---|
static class |
QBChatService.ConfigurationBuilder |
Modifier and Type | Method and Description |
---|---|
void |
addConnectionListener(ConnectionListener connectionListener)
Adds a connection listener that will be notified when the connection closes or fails.
|
void |
destroy()
Destroys the Chat service.
|
void |
disableCarbons()
Disable carbons.
|
void |
enableCarbons()
Enable carbons.
|
void |
enterActiveState()
Notifies server when mobile client is entering active state.
|
void |
enterInactiveState()
Notifies server when mobile client is entering inactive state.
|
boolean |
getCarbonsEnabled()
Check if carbons are enabled on this connection.
|
static long |
getDefaultAutoSendPresenceInterval() |
static long |
getDefaultConnectionTimeout()
How long the socket will wait until a TCP connection is established (in milliseconds).
|
static int |
getDefaultPacketReplyTimeout()
Returns the number of milliseconds to wait for a response from the server.
|
QBGroupChatManager |
getGroupChatManager()
Obtains the QBGroupChatManager instance.
|
QBIncomingMessagesManager |
getIncomingMessagesManager()
Obtains the QBIncomingMessagesManager instance.
|
static QBChatService |
getInstance()
Obtains QBChatService singleton instance
|
long |
getLastUserActivity(java.lang.Integer userId)
Returns the last activity of a particular user.
|
QBMessageStatusesManager |
getMessageStatusesManager()
Obtains the QBMessageStatusesManager instance.
|
QBPingManager |
getPingManager()
Obtains the QBPingManager instance.
|
QBPrivacyListsManager |
getPrivacyListsManager()
Obtains the QBPrivacyListsManager instance.
|
QBPrivateChatManager |
getPrivateChatManager()
Obtains the QBPrivateChatManager instance.
|
QBRoster |
getRoster()
Obtains the QBRoster instance.
|
QBRoster |
getRoster(QBRoster.SubscriptionMode mode,
QBSubscriptionListener subscriptionListener)
Obtains the QBRoster instance and set the subscription listener.
|
QBSystemMessagesManager |
getSystemMessagesManager()
Obtains the QBSystemMessagesManager instance.
|
QBUser |
getUser()
Retrieves current currentUser
|
QBVideoChatWebRTCSignalingManager |
getVideoChatWebRTCSignalingManager() |
boolean |
isAutojoinEnabled() |
static boolean |
isDebugEnabled()
Returns the value that indicates whether debugging is enabled.
|
boolean |
isLoggedIn()
Returns true if currently logged in by successfully calling the login method.
|
boolean |
isReconnectionAllowed()
Returns if the reconnection mechanism is allowed to be used.
|
boolean |
isStreamManagementEnabled()
Returns true if Stream Management should be used if supported by the server.
|
void |
login(QBUser user)
Logs in a currentUser to Chat, then sets presence to available.
|
void |
login(QBUser user,
QBEntityCallback callback)
Logs in a currentUser to Chat, asynchronously, then sets presence to available.
|
void |
login(QBUser user,
java.lang.String resource)
Logs in a currentUser to Chat with custom resource, then sets presence to available.
|
void |
login(QBUser user,
java.lang.String resource,
QBEntityCallback<java.lang.Void> callback)
Logs in a currentUser to Chat with custom resource, asynchronously, then sets presence to available.
|
void |
logout()
Logs out by setting presence to unavailable then closing the connection to the Chat server.
|
void |
logout(QBEntityCallback<java.lang.Void> callback)
Logs out by setting presence to unavailable then closing the connection to the Chat server, asynchronously.
|
void |
removeConnectionListener(ConnectionListener connectionListener)
Removes a connection listener
|
static void |
setConfigurationBuilder(QBChatService.ConfigurationBuilder configurationBuilder) |
static void |
setConnectionFabric(AbstractChatConnectionFabric connectionFabric) |
static void |
setDebugEnabled(boolean debugEnabled)
Sets the value that indicates whether debugging is enabled.
|
static void |
setDefaultAutoSendPresenceInterval(long intervalInSeconds)
Set interval to send presence to server to keep connection active
|
static void |
setDefaultConnectionTimeout(long connectTimeout) |
static void |
setDefaultPacketReplyTimeout(int timeout)
Sets the number of milliseconds to wait for a response from the server.
|
void |
setPreferredResumptionTime(int resumptionTime)
Set the preferred resumption time in seconds.
|
void |
setReconnectionAllowed(boolean reconnectionAllowed)
Sets if the reconnection mechanism is allowed to be used.
|
void |
setUseStreamManagement(boolean useSm)
Set if Stream Management should be used if supported by the server.
|
void |
setUseStreamManagementResumption(boolean useSmResumption)
Set if Stream Management resumption should be used if supported by the server.
|
void |
startAutoSendPresence(long intervalInSeconds)
Enable auto sending presences to stay connected to Chat.
|
void |
stopAutoSendPresence()
Disable auto sending presences.
|
createBaseService, createFromExistentToken, getBaseService, getToken, getTokenExpirationDate, resetCredentials, setToken, setTokenExpirationDate
public static void setConnectionFabric(AbstractChatConnectionFabric connectionFabric)
public static QBChatService getInstance()
public static boolean isDebugEnabled()
public static void setDebugEnabled(boolean debugEnabled)
debugEnabled
- true -> enable debug, false -> disable debug.public static void setDefaultPacketReplyTimeout(int timeout)
timeout
- The milliseconds to wait for a response from the server.public static int getDefaultPacketReplyTimeout()
public static long getDefaultConnectionTimeout()
public static void setDefaultConnectionTimeout(long connectTimeout)
public static long getDefaultAutoSendPresenceInterval()
public static void setDefaultAutoSendPresenceInterval(long intervalInSeconds)
intervalInSeconds
- interval to send presences, in seconds.public static void setConfigurationBuilder(QBChatService.ConfigurationBuilder configurationBuilder)
public boolean isAutojoinEnabled()
public void login(QBUser user) throws XMPPException, java.io.IOException, SmackException
user
- The currentUser to log in with. Required currentUser's fields: ID, password.XMPPException
- if an error occurs on the XMPP protocol level.SmackException
- if an error occurs somewhere else besides XMPP protocol level.java.io.IOException
QBUser
public void login(QBUser user, java.lang.String resource) throws XMPPException, java.io.IOException, SmackException
user
- The currentUser to log in with. Required currentUser's fields: ID, password.resource
- The resource.XMPPException
- if an error occurs on the XMPP protocol level.SmackException
- if an error occurs somewhere else besides XMPP protocol level.java.io.IOException
QBUser
public void login(QBUser user, QBEntityCallback callback)
user
- The currentUser to log in with. Required currentUser's fields: ID, password.callback
- The callback, must implement QBEntityCallback interface.QBUser
public void login(QBUser user, java.lang.String resource, QBEntityCallback<java.lang.Void> callback)
user
- The currentUser to log in with. Required currentUser's fields: ID, password.resource
- The resource.callback
- The result callback, must implement QBEntityCallback interface.QBUser
public void logout(QBEntityCallback<java.lang.Void> callback)
callback
- The result callback, must implement QBEntityCallback interface.public void logout() throws SmackException.NotConnectedException
SmackException.NotConnectedException
public void enterInactiveState() throws SmackException.NotConnectedException
SmackException.NotConnectedException
public void enterActiveState() throws SmackException.NotConnectedException
SmackException.NotConnectedException
public void startAutoSendPresence(long intervalInSeconds)
intervalInSeconds
- interval to send presences, in seconds.public void stopAutoSendPresence()
public void destroy()
public QBRoster getRoster()
public QBRoster getRoster(QBRoster.SubscriptionMode mode, QBSubscriptionListener subscriptionListener)
public QBPrivateChatManager getPrivateChatManager()
public QBMessageStatusesManager getMessageStatusesManager()
public QBGroupChatManager getGroupChatManager()
public QBVideoChatWebRTCSignalingManager getVideoChatWebRTCSignalingManager()
public QBPrivacyListsManager getPrivacyListsManager()
public QBPingManager getPingManager()
public QBSystemMessagesManager getSystemMessagesManager()
public QBIncomingMessagesManager getIncomingMessagesManager()
public boolean isLoggedIn()
public void addConnectionListener(ConnectionListener connectionListener)
connectionListener
- a connection listener.public void removeConnectionListener(ConnectionListener connectionListener)
connectionListener
- a connection listener.public boolean isReconnectionAllowed()
public void setReconnectionAllowed(boolean reconnectionAllowed)
reconnectionAllowed
- if the reconnection mechanism is allowed to use.public void setUseStreamManagement(boolean useSm)
useSm
- true to use Stream Management.public boolean isStreamManagementEnabled()
public void setUseStreamManagementResumption(boolean useSmResumption)
useSmResumption
- true to use Stream Management resumption.public void setPreferredResumptionTime(int resumptionTime)
resumptionTime
- the preferred resumption time in secondspublic void enableCarbons() throws XMPPException, SmackException
XMPPException
SmackException
- if there was no response from the server.public void disableCarbons() throws XMPPException, SmackException
XMPPException
SmackException
- if there was no response from the server.public boolean getCarbonsEnabled()
public long getLastUserActivity(java.lang.Integer userId) throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException
userId
- the ID of user which want to get last activity time.XMPPException.XMPPErrorException
- thrown if a server error has occured (e.g. requested user never logged in to chat).SmackException.NotConnectedException
- if current user not connected to the chat.SmackException.NoResponseException
- if didn't get response for a specified reply timeout.