Make connection problems visible in the UI.
This commit is contained in:
@@ -19,6 +19,13 @@ $(function () {
|
|||||||
$.getJSON('/token', function (tokenResponse) {
|
$.getJSON('/token', function (tokenResponse) {
|
||||||
//Initialize the Sync client
|
//Initialize the Sync client
|
||||||
syncClient = new Twilio.Sync.Client(tokenResponse.token, { logLevel: 'info' });
|
syncClient = new Twilio.Sync.Client(tokenResponse.token, { logLevel: 'info' });
|
||||||
|
syncClient.on('connectionStateChanged', function(state) {
|
||||||
|
if (state != 'connected') {
|
||||||
|
$message.html('Sync is not live (websocket connection <span style="color: red">' + state + '</span>)…');
|
||||||
|
} else {
|
||||||
|
$message.html('Sync is live!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
//Let's pop a message on the screen to show that Sync is ready
|
//Let's pop a message on the screen to show that Sync is ready
|
||||||
$message.html('Sync initialized!');
|
$message.html('Sync initialized!');
|
||||||
|
|||||||
Reference in New Issue
Block a user