public class CocoClient
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
CocoClient.AccessTokensListener
The listener which will be triggered after the
NativeCallbacks.accessTokenCallback(java.lang.String, int, java.lang.Object) . |
static class |
CocoClient.Configurator
NOTE: This is a singleton builder.
|
static class |
CocoClient.ConnectivityMode
An enum denoting possible values of mode of connectivity.
|
static class |
CocoClient.ConnectivityTimers
This class defines default SDK timeouts and allows developer to set his/her own SDK timers.
|
static interface |
CocoClient.NetworkListListener
The listener which will be triggered after the
NativeCallbacks.networkListCallback(java.lang.String[], java.lang.String[], int[], int[], int[], java.lang.Object) . |
Modifier and Type | Method and Description |
---|---|
void |
addSubscription(CallbacksInterface nativeCallbacks)
A function to add extra subscribers for callbacks.
|
protected void |
clearNetworks() |
void |
clearSubscriptions()
A function to clear all the subscriptions to the NativeCallbacks.
|
boolean |
containsNetwork(java.lang.String networkId) |
void |
getAccessTokens(CocoClient.AccessTokensListener listener)
This function can be used to get OAuth Tokens from the c-sdk.
|
void |
getAllNetworks(CocoClient.NetworkListListener listener)
This function is used to request the available networks from the
server.
|
static CocoClient |
getInstance()
This function returns the CocoClient instance that was created earlier.
|
<T extends Network> |
getNetwork(java.lang.String networkId) |
java.util.Map<java.lang.String,Network> |
getNetworkMap()
This function is used to return the HashMap that the sdk uses to map the
networkIds to the network Objects.
|
Network[] |
getSavedNetworks()
This function return an array of networks which are previous connected by user.
|
java.lang.String |
getVersionInfo() |
void |
informNetworkChange() |
protected void |
internalAddNetwork(Network network) |
protected void |
internalRemoveNetwork(java.lang.String networkId) |
void |
invalidateAccessToken()
A function to invalidate the current accessToken.
|
void |
removeSubscription(CallbacksInterface nativeCallbacks)
A function to remove the subscription of an object.
|
Network |
restoreNetworkState(java.lang.String jsonNetworkState)
A function to restore the state of the network during second run.
|
void |
setConnectivityMode(CocoClient.ConnectivityMode mode)
sets the connectivity mode using Native method defined using JNI.
|
void |
setListener(PlatformInterface listener)
A function to set the listener for Platform callbacks.
|
void |
setTokens(java.lang.String response)
This function must be called when OAuthCallback is received.
|
public java.lang.String getVersionInfo()
public void clearSubscriptions()
public void addSubscription(CallbacksInterface nativeCallbacks)
nativeCallbacks
- The object which has to be notifiedpublic void removeSubscription(CallbacksInterface nativeCallbacks)
nativeCallbacks
- The object which has to be removedpublic void setListener(PlatformInterface listener)
listener
- The listener which will get the callbackspublic void invalidateAccessToken()
java.lang.RuntimeException
- on Failurepublic static CocoClient getInstance()
public Network[] getSavedNetworks()
Native.nativeGetSavedNetworks()
.public void getAllNetworks(CocoClient.NetworkListListener listener)
public Network restoreNetworkState(java.lang.String jsonNetworkState)
jsonNetworkState
- The json formatted string which is returned by
Network.saveState()
com.google.gson.JsonParseException
- on malformed JSONsjava.lang.IllegalStateException
- on initiating restore on already connected
or connecting networksNetwork.saveState()
public void setTokens(java.lang.String response)
NativeCallbacks.authCallback(java.lang.String, java.lang.String)
is received to set the tokens.response
- The stringified JSON response.java.lang.RuntimeException
- Throws an exception on failure to setTokens in database.public void getAccessTokens(CocoClient.AccessTokensListener listener)
listener
- The listener that is triggered after callbacks.public java.util.Map<java.lang.String,Network> getNetworkMap()
public boolean containsNetwork(java.lang.String networkId)
protected void internalAddNetwork(Network network)
protected void internalRemoveNetwork(java.lang.String networkId)
protected void clearNetworks()
public <T extends Network> T getNetwork(java.lang.String networkId)
public void setConnectivityMode(CocoClient.ConnectivityMode mode)
mode
- CocoClient.ConnectivityMode
public void informNetworkChange()