Sync Android SDK  1.0.3
com.twilio.sync.SyncClient Interface Reference

This is a central entity used to work with Sync. More...

Classes

enum  ConnectionState
 Enum representing underlying twilsock connection state. More...
 
class  LogLevel
 Log level constants for passing to setLogLevel. More...
 
interface  Properties
 Specify properties for creating new Sync Client. More...
 
interface  SyncClientListener
 This interface defines SyncClient callback methods. More...
 

Public Member Functions

void updateToken (@NonNull String accessToken, SuccessListener< Void > listener)
 Update SyncClient with a refreshed token. More...
 
void shutdown ()
 Cleanly shut down the SyncClient and free up associated resources. More...
 
void openDocument (SyncOptions options, SyncDocumentObserver observer, SuccessListener< SyncDocument > output)
 Open or create a SyncDocument object. More...
 
void openList (SyncOptions options, SyncListObserver observer, SuccessListener< SyncList > output)
 Open or create a SyncList object. More...
 
void openMap (SyncOptions options, SyncMapObserver observer, SuccessListener< SyncMap > output)
 Open or create a SyncMap object. More...
 
void openStream (SyncOptions options, SyncStreamObserver observer, SuccessListener< SyncStream > output)
 Open or create a SyncStream object. More...
 
ConnectionState getConnectionState ()
 
void setListener (SyncClientListener listener)
 Set new listener on the client. More...
 

Static Public Member Functions

static void create (@NonNull Context context, String accessToken, Properties props, SuccessListener< SyncClient > listener)
 Public factory method to create a new instance of Sync Client. More...
 
static String getSdkVersion ()
 
static void setLogLevel (int level)
 Set verbosity level for log messages to be printed to android logcat. More...
 

Detailed Description

This is a central entity used to work with Sync.

After creating a SyncClient you can open, create and modify SyncDocuments, SyncLists, SyncMaps and SyncStreams.

todo: more detailed description with code examples please.

Member Function Documentation

static void com.twilio.sync.SyncClient.create ( @NonNull Context  context,
String  accessToken,
Properties  props,
SuccessListener< SyncClient listener 
)
static

Public factory method to create a new instance of Sync Client.

Parameters
contextPass Application Context here, cannot be null.
accessTokenAccess token containing at least a Sync Grant to access sync features.
propsProperties for initializing client.
Properties.defaultProperties()
could be commonly used. See Properties for more details.
listenerListener to receive the newly created Sync Client.
ConnectionState com.twilio.sync.SyncClient.getConnectionState ( )
Returns
Current transport state.
static String com.twilio.sync.SyncClient.getSdkVersion ( )
static
Returns
The version of the Sync SDK.
void com.twilio.sync.SyncClient.openDocument ( SyncOptions  options,
SyncDocumentObserver  observer,
SuccessListener< SyncDocument output 
)

Open or create a SyncDocument object.

Parameters
optionsSyncOptions that specify open mode and possible SID or Unique Name of the SyncDocument.
observerObserver to receive callbacks on all actions performed on the document both locally and remotely.
outputListener that will receive opened document in its onSuccess() callback or any error in onError() callback.
void com.twilio.sync.SyncClient.openList ( SyncOptions  options,
SyncListObserver  observer,
SuccessListener< SyncList output 
)

Open or create a SyncList object.

Parameters
optionsSyncOptions that specify open mode and possible SID or Unique Name of the SyncList.
observerObserver to receive callbacks on all actions performed on the list both locally and remotely.
outputListener that will receive opened list in its onSuccess() callback or any error in onError() callback.
void com.twilio.sync.SyncClient.openMap ( SyncOptions  options,
SyncMapObserver  observer,
SuccessListener< SyncMap output 
)

Open or create a SyncMap object.

Parameters
optionsSyncOptions that specify open mode and possible SID or Unique Name of the SyncMap.
observerObserver to receive callbacks on all actions performed on the map both locally and remotely.
outputListener that will receive opened map in its onSuccess() callback or any error in onError() callback.
void com.twilio.sync.SyncClient.openStream ( SyncOptions  options,
SyncStreamObserver  observer,
SuccessListener< SyncStream output 
)

Open or create a SyncStream object.

Parameters
optionsSyncOptions that specify open mode and possible SID or Unique Name of the SyncStream.
observerObserver to receive callbacks on all actions performed on the stream both locally and remotely.
outputListener that will receive opened stream in its onSuccess() callback or any error in onError() callback.
void com.twilio.sync.SyncClient.setListener ( SyncClientListener  listener)

Set new listener on the client.

Set to null to clear. As soon as listener is set it will receive onConnectionStateChanged callback with the current state of the connection.

Parameters
listenerNew listener to use or null to remove listener.
static void com.twilio.sync.SyncClient.setLogLevel ( int  level)
static

Set verbosity level for log messages to be printed to android logcat.

Default log level is LogLevel#SILENT.

Parameters
levelVerbosity level. See LogLevel for supported options.
void com.twilio.sync.SyncClient.shutdown ( )

Cleanly shut down the SyncClient and free up associated resources.

Call this when exiting application or when done working with the SyncClient to properly finish working with Sync.

Avoid calling methods on Sync objects from their own callback events, as it may lead to unexpected nesting and poorly predictable behavior. SyncClient shutdown method must not be called from an event callback.

It will dispose() the client after shutdown, so it could not be reused.

void com.twilio.sync.SyncClient.updateToken ( @NonNull String  accessToken,
SuccessListener< Void >  listener 
)

Update SyncClient with a refreshed token.

Parameters
accessTokenNew access token containing at least a Sync Grant to access sync features.
listenerListener to receive status of the operation.