Sync Android SDK  2.0.1
com.twilio.sync.SyncStreamObserver Class Referenceabstract

Observer for all operations on a SyncStream. More...

Public Member Functions

 SyncStreamObserver ()
 Keep default constructor, you don't need to override it. More...
 
void onOpened (SyncStream syncStream)
 This callback is invoked when SyncStream object has been initialised and opened locally. More...
 
void onRemoved (EventContext context)
 This callback is invoked when the SyncStream has been removed. More...
 
void onMessagePublished (EventContext context, SyncStream.Message message)
 This callback is invoked when SyncStream has successfully published a message. More...
 
void onErrorOccurred (ErrorInfo error)
 This callback is invoked when a SyncStream operation has encountered a error in local request. More...
 

Detailed Description

Observer for all operations on a SyncStream.

You should create your own subclass of StreamObserver and override functions you are interested in.

Observer will receive callbacks for all operations on a SyncStream. To distinguish parallel streams of local operations your application could use local flow identifier.

Callbacks in the observer will be called from a background thread. You will need to repost your work to UI thread if you do any UI-related operations in the callback.

Constructor & Destructor Documentation

com.twilio.sync.SyncStreamObserver.SyncStreamObserver ( )

Keep default constructor, you don't need to override it.

If you do override make sure to call the inherited constructor.

Member Function Documentation

void com.twilio.sync.SyncStreamObserver.onErrorOccurred ( ErrorInfo  error)

This callback is invoked when a SyncStream operation has encountered a error in local request.

Parameters
errorError description.
void com.twilio.sync.SyncStreamObserver.onMessagePublished ( EventContext  context,
SyncStream.Message  message 
)

This callback is invoked when SyncStream has successfully published a message.

Parameters
contextContext indicating if change was local or remote.
messageSnapshot of the received message.
void com.twilio.sync.SyncStreamObserver.onOpened ( SyncStream  syncStream)

This callback is invoked when SyncStream object has been initialised and opened locally.

Parameters
syncStreamSyncStream object that has been opened. This parameter you should take and use as your initialised instance of a stream.
void com.twilio.sync.SyncStreamObserver.onRemoved ( EventContext  context)

This callback is invoked when the SyncStream has been removed.

Parameters
contextContext indicating if change was local or remote.