diff --git a/app.py b/app.py index 40ee893..a56dc8a 100644 --- a/app.py +++ b/app.py @@ -60,16 +60,12 @@ def token(): # create a randomly generated username for the client identity = fake.user_name() - # Create a unique endpoint ID for the - device_id = request.args.get('device') - endpoint = "TwilioAppDemo:{0}:{1}".format(identity, device_id) - # Create access token with credentials token = AccessToken(account_sid, api_key, api_secret, identity) # Create a Sync grant and add to token if sync_service_sid: - sync_grant = SyncGrant(endpoint_id=endpoint, service_sid=sync_service_sid) + sync_grant = SyncGrant(service_sid=sync_service_sid) token.add_grant(sync_grant) # Create a Video grant and add to token diff --git a/static/sync/index.html b/static/sync/index.html index 2820760..796886d 100755 --- a/static/sync/index.html +++ b/static/sync/index.html @@ -44,7 +44,7 @@ - + diff --git a/static/sync/index.js b/static/sync/index.js index f0ad9dc..d585191 100755 --- a/static/sync/index.js +++ b/static/sync/index.js @@ -5,9 +5,6 @@ $(function () { //Get handle to the game board buttons var $buttons = $('#board .board-row button'); - //Manages the state of our access token we got from the server - var accessManager; - //Our interface to the Sync service var syncClient; @@ -19,11 +16,9 @@ $(function () { //In browser-based apps, every tab is like its own unique device //synchronizing state -- so we'll use a random UUID to identify //this tab. - $.getJSON('/token', { - device: getDeviceId() - }, function (tokenResponse) { + $.getJSON('/token', function (tokenResponse) { //Initialize the Sync client - syncClient = new Twilio.Sync.Client(tokenResponse.token); + syncClient = new Twilio.Sync.Client(tokenResponse.token, { logLevel: 'info' }); //Let's pop a message on the screen to show that Sync is ready $message.html('Sync initialized!'); @@ -78,17 +73,6 @@ $(function () { } } - //Generate random UUID to identify this browser tab - //For a more robust solution consider a library like - //fingerprintjs2: https://github.com/Valve/fingerprintjs2 - function getDeviceId() { - return 'browser-' + - 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { - var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); - return v.toString(16); - }); - } - //Read the state of the UI and create a new document function readGameBoardFromUserInterface() { var board = [ @@ -120,4 +104,4 @@ $(function () { } } -}); +}); \ No newline at end of file