public final class Platform extends Object
By design, Platform is singleton; there will be one platform instance
in memory at any given point
| Modifier and Type | Method and Description |
|---|---|
static void |
addEventHandler(Event.EventType type,
EventHandler handler)
Convenience method to add
EventHandler to EventBus in
session |
static <E extends Event> |
addEventListener(Class<E> eventClz,
EventListener<E> listener)
Convenience method to add
EventListener to EventBus in
session |
void |
addUndeliveredStanzaManager(UndeliveredStanzaManager undeliveredStanzaManager) |
void |
clearUserSession()
Clears user session data.
|
static Object |
get(String key)
Convenience method to get stored value for some key.
|
ChatManager |
getChatManager() |
String |
getDomain()
Returns domain name
|
static Platform |
getInstance() |
JID |
getJabberSearchServiceJID() |
int |
getMaxResumptionTimeInSec(int defaultValue) |
JID |
getMucServiceJID()
Returns MUC service JID
|
String |
getMucServiceName()
Returns MUC service name
|
PresenceManager |
getPresenceManager() |
ResponseCorrelator |
getResponseCorrelator() |
JID |
getServerJID()
Returns domain name
|
UndeliveredStanzaManager |
getUndeliveredStanzaManager() |
JID |
getUserJID()
Return logged in user's
JID |
UserManager |
getUserManager() |
String |
getUserName()
Return logged in user's name
|
Session |
getUserSession() |
static boolean |
initialize(SDKInitializer initializer)
Initialize SDK Platform.
|
boolean |
isSMSupported(boolean defaultValue) |
boolean |
isUserAuthenticated()
Return user is authenticated or not on current stream.
|
StreamNegotiator.NegotiationResult |
login(String userName,
String domain,
String passwd)
Start XMPP stream with given user credentials.
|
void |
login(String userName,
String domain,
String passwd,
Callback<StreamNegotiator.NegotiationResult,Exception> callback)
Start XMPP stream with given user credentials.
|
void |
logout()
User logout is protocol level action which simply closes the ongoing
stream with server.
|
static void |
put(String key,
Object value)
Convenience method to store some key values in user session.
|
static void |
raiseEvent(Event.EventType type,
Object source)
Raise event which is fired on the event bus held by the user session
|
boolean |
registerPacketCollector(PacketCollector collector,
String fName)
Register a
PacketCollector with a PacketForwarder to tap
into the packet stream |
static void |
removeEventHandler(Event.EventType type,
EventHandler handler)
Convenience method to remove
EventHandler to EventBus in
session |
void |
removeUndeliveredStanzaManager() |
void |
setIsSMSupported(boolean isSupported) |
void |
setMaxResumptionTimeInSec(int maxResumptionTimeInSec) |
void |
shutdown()
Shutdown this platform instance; this action is irreversible.
|
public static final String CHAT
public static final String DOT
public static Platform getInstance()
initialize(SDKInitializer) before invoking this
method, the call will throw NotInitializedException which
is a RuntimeExceptionpublic static boolean initialize(SDKInitializer initializer) throws InitializationErrorException
NotInitializedExceptioninitializer - SDKInitializer instance which will be used by
the Platform to instantiate SDK objectsInitializationErrorException - indicating platform initialization
failurepublic void clearUserSession()
public String getUserName()
public String getDomain()
public JID getServerJID() throws InvalidJabberId
JID of the serverInvalidJabberId - if the JID format is not correctpublic String getMucServiceName()
public JID getMucServiceJID() throws InvalidJabberId
JIDInvalidJabberId - if the JID instantiation failspublic JID getJabberSearchServiceJID()
public void addUndeliveredStanzaManager(UndeliveredStanzaManager undeliveredStanzaManager)
public void removeUndeliveredStanzaManager()
public UndeliveredStanzaManager getUndeliveredStanzaManager()
public void setIsSMSupported(boolean isSupported)
public boolean isSMSupported(boolean defaultValue)
public void setMaxResumptionTimeInSec(int maxResumptionTimeInSec)
public int getMaxResumptionTimeInSec(int defaultValue)
public static void put(String key, Object value)
key - String keyvalue - value objectpublic static Object get(String key)
key - key for the value to be retrievedpublic static void raiseEvent(Event.EventType type, Object source)
type - type of the event to be raisedsource - source object instancepublic static <E extends Event> void addEventListener(Class<E> eventClz, EventListener<E> listener)
EventListener to EventBus in
sessionE - genericeventClz - event class for which event listener will be invokedlistener - event listener instancepublic static void addEventHandler(Event.EventType type, EventHandler handler)
EventHandler to EventBus in
sessiontype - Event.EventTypehandler - EventHandler instancepublic static void removeEventHandler(Event.EventType type, EventHandler handler)
EventHandler to EventBus in
sessiontype - Event.EventTypehandler - EventHandler instancepublic boolean registerPacketCollector(PacketCollector collector, String fName)
PacketCollector with a PacketForwarder to tap
into the packet streamcollector - PacketCollector to be registeredfName - PacketForwarder namePacketForwarder was found registered with
Platform and given collector was registered with the forwarder
otherwise falsepublic StreamNegotiator.NegotiationResult login(String userName, String domain, String passwd) throws NetworkException
userName - userName of the user trying to loginpasswd - user passworddomain - user domain in which user will loginStreamNegotiator.NegotiationResult instance with stream negotiation
outcomeNetworkException - if IO error occurs while reading/writing on
connectionpublic void login(String userName, String domain, String passwd, Callback<StreamNegotiator.NegotiationResult,Exception> callback)
Callback will be invoked with StreamNegotiator.NegotiationResult
object which application can process to find out the exact outcome of the
negotiation process.
During negotiations, if IO error occurs while writing/reading on/from
socket, Callback will be invoked with NetworkException.
Additionally, if the underlying device does not have network
connectivity, Callback will be invoked with
NetworkException with NetworkException.Reason.NO_CONNECTIVITY
userName - userName of the user trying to logindomain - user domain in which user will loginpasswd - user passwordcallback - callback implementation to be invokedpublic boolean isUserAuthenticated()
public ChatManager getChatManager()
ChatManager instancepublic PresenceManager getPresenceManager()
PresenceManager instancepublic UserManager getUserManager()
UserManager instancepublic ResponseCorrelator getResponseCorrelator()
ResponseCorrelator instancepublic void logout()
throws NetworkException
NetworkException - when there is any network related errorpublic void shutdown()
ChatManager and PresenceManager) along with XMPP Stream
are shutdown and connections are closed.
Once the Platform is shutdown, it's state can not be reconstructed; therefore it's the final call to the Platform. Typically when application is getting removed from memeory, Platform will be shutdown. For actions such as user logout, the platform should also be logged out instead of shutdown.
Copyright © 2019. All rights reserved.