-
publishMessage(value)
-
Publish a Message to the Stream. The system will attempt delivery to all online subscribers.
Parameters:
| Name |
Type |
Description |
value |
Object
|
The body of the dispatched message. Maximum size in serialized JSON: 4KB.
A rate limit applies to this operation, refer to the Sync API documentation for details. |
Returns:
A promise which resolves after the message is successfully published
to the Sync service. Resolves irrespective of ultimate delivery to any subscribers.
-
Type
-
Promise.<StreamMessage>
Example
stream.publishMessage({ x: 42, y: 123 })
.then(function(message) {
console.log('Stream publishMessage() successful, message SID:' + message.sid);
})
.catch(function(error) {
console.error('Stream publishMessage() failed', error);
});
-
removeStream()
-
Permanently delete this Stream.
Returns:
A promise which resolves after the Stream is successfully deleted.
-
Type
-
Promise.<void>
Example
stream.removeStream()
.then(function() {
console.log('Stream removeStream() successful');
})
.catch(function(error) {
console.error('Stream removeStream() failed', error);
});
-
setTtl(ttl)
-
Update the time-to-live of the stream.
Parameters:
| Name |
Type |
Description |
ttl |
Number
|
Specifies the TTL in seconds after which the stream is subject to automatic deletion. The value 0 means infinity. |
Returns:
A promise that resolves after the TTL update was successful.
-
Type
-
Promise.<void>
Example
stream.setTtl(3600)
.then(function() {
console.log('Stream setTtl() successful');
})
.catch(function(error) {
console.error('Stream setTtl() failed', error);
});