public interface SyncStream
You can publish messages and listen for incoming messages.
To obtain an instance of a SyncStream use SyncClient.openStream(com.twilio.sync.SyncOptions, com.twilio.sync.SyncStreamObserver, com.twilio.sync.SuccessListener<com.twilio.sync.SyncStream>).
| Modifier and Type | Interface and Description |
|---|---|
static interface |
SyncStream.Message
Single message in a SyncStream.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
INFINITE_DURATION
Time to live for a stream, specifying no expiry.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getSid()
An immutable system-assigned identifier of this Message SyncStream.
|
java.lang.String |
getUniqueName()
An optional unique name for this stream, assigned at creation time.
|
void |
publishMessage(org.json.JSONObject data,
SuccessListener<java.lang.String> listener)
Publish a new message to this message stream.
|
void |
removeStream(SuccessListener<java.lang.Void> listener)
Remove the stream from the system, deleting it.
|
void |
setTtl(int ttl,
SuccessListener<java.lang.Void> listener)
Set time to live for stream object in seconds.
|
static final int INFINITE_DURATION
java.lang.String getSid()
java.lang.String getUniqueName()
void publishMessage(org.json.JSONObject data,
SuccessListener<java.lang.String> listener)
data - Contains the payload of the dispatched message. Maximum size in serialized JSON: 4KB.listener - Async result listener. See SuccessListener.void setTtl(int ttl,
SuccessListener<java.lang.Void> listener)
This TTL specifies the minimum time the SyncStream will live, sometime soon after this time the object will be deleted.
If time to live is not specified, object lives infinitely long.
TTL could be used in order to auto-recycle old unused objects, but it is not recommended to build some app logic like timers using ttl.
ttl - Time to live in seconds from now or INFINITE_DURATION to indicate no expiry.listener - Async result listener. See SuccessListener.void removeStream(SuccessListener<java.lang.Void> listener)
listener - Async result listener. See SuccessListener.