Make connection problems visible in the UI.

This commit is contained in:
Andres Jaan Tack
2017-11-30 15:37:17 +02:00
parent f785244e45
commit 80e4744787

View File

@@ -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!');