new Twilio.Sync.Client()
Properties:
Name | Type | Description |
---|---|---|
connectionState |
Client#ConnectionState | Contains current service connection state. Valid options are ['connecting', 'connected', 'disconnecting', 'disconnected', 'denied', 'error']. |
Members
-
<readonly> version :String
-
Current version of Sync client.
Type:
- String
Methods
-
document(id)
-
Open a Sync Document by identifier, or create one if none exists
Parameters:
Name Type Description id
string a Unique name or SID identifying a Sync Document. Returns:
a promise which resolves after the document is successfully read (or created). This promise may reject if the document could not be created or if this endpoint lacks the necessary permissions to access to it.- Type
- Promise.<List>
-
list(id)
-
Open a Sync List by identifier, or create one if none exists
Parameters:
Name Type Description id
string a Unique name or SID identifying a Sync List. Returns:
a promise which resolves after the list is successfully read (or created). This promise may reject if the list could not be created or if this endpoint lacks the necessary permissions to access to it.- Type
- Promise.<List>
-
map(id)
-
Open a Sync Map by identifier, or create one if none exists
Parameters:
Name Type Description id
string a Unique name or SID identifying a Sync Map. Returns:
a promise which resolves after the map is successfully read (or created). This promise may reject if the map could not be created or if this endpoint lacks the necessary permissions to access to it.- Type
- Promise.<Map>
-
stream(id)
-
Open a Sync Message Stream (SyncStream) by identifier, or create one if none exists
Parameters:
Name Type Description id
string a Unique name or SID identifying a Sync Message Stream. Returns:
a promise which resolves after the stream is successfully read (or created). The flow of messages will begin imminently (but not necessarily immediately) upon resolution. This promise may reject if the stream could not be created or if this endpoint lacks the necessary permissions to access it.- Type
- Promise.<Stream>
-
updateToken(token)
-
Set new auth token
Parameters:
Name Type Description token
string New token to set Returns:
- Type
- Promise
Type Definitions
-
ClientOptions
-
These options can be passed to Client constructor
Type:
- Object
Properties:
Name Type Argument Default Description logLevel
String <optional>
'error' The level of logging to enable. Valid options (from strictest to broadest): ['silent', 'error', 'warn', 'info', 'debug', 'trace'] -
ConnectionState
-
Indicates current state of connection between the client and Sync service.
Valid options are as follows:
- 'connecting' - client is offline and connection attempt is in process.
- 'connected' - client is online and ready.
- 'disconnecting' - client is going offline as disconnection is in process.
- 'disconnected' - client is offline and no connection attempt is in process.
- 'denied' - client connection is denied because of invalid JWT access token. User must refresh token in order to proceed.
- 'error' - client connection is in a permanent erroneous state. Client re-initialization is required.
Type:
- 'connecting' | 'connected' | 'disconnecting' | 'disconnected' | 'denied' | 'error'
Events
-
connectionStateChanged
-
Fired when connection state has been changed.
Parameters:
Name Type Description connectionState
Client#ConnectionState Contains current service connection state.