JSON payload instead of string

citations
Fabien Benetou 9 months ago
parent ac4dc57975
commit 20dca36947
  1. 15
      index.html

@ -99,8 +99,14 @@ function manualAnimate(selector="#biggu"){
} }
// see https://biggu-backend-collab.glitch.me/ to insure steps are done correctly // see https://biggu-backend-collab.glitch.me/ to insure steps are done correctly
function shareLiveEvent(eventName, server='https://biggu-backend-collab.glitch.me/'){ function shareLiveEvent(eventName, eventData, server='https://biggu-backend-collab.glitch.me/'){
if (eventName.length > 0) fetch(server+'/newevent/'+eventName) if (!eventName) return
let data = {}
data.eventName = eventName
if (eventData) data.eventData = eventData
let playername = AFRAME.utils.getUrlParameter('playername')
if (playername) data.playername = playername
fetch(server+'/newevent/'+JSON.stringify(data))
} }
// should then become a container hosted on benetou.fr // should then become a container hosted on benetou.fr
@ -141,7 +147,7 @@ function checkExerciseCompletion(targetNumber=2){
} else { } else {
document.getElementById("biggucontinu").play() document.getElementById("biggucontinu").play()
instructions.emit('failed', {counter:counter}) instructions.emit('failed', {counter:counter})
shareLiveEvent('failed'+' '+counter) shareLiveEvent('failed', {counter:counter})
animateThenIdle(mainCharacter, 'bigguaction_yes') animateThenIdle(mainCharacter, 'bigguaction_yes')
// anims = [ "bigguaction_no", "Bigguaction_pl", "bigguaction_pr", "bigguaction_talk", "bigguaction_win", "bigguaction_win", "bigguaction_yes" ] // anims = [ "bigguaction_no", "Bigguaction_pl", "bigguaction_pr", "bigguaction_talk", "bigguaction_win", "bigguaction_win", "bigguaction_yes" ]
} }
@ -194,7 +200,8 @@ AFRAME.registerComponent('start-with-supervision', {
source.addEventListener('message', message => { source.addEventListener('message', message => {
console.log('Got', message); console.log('Got', message);
if (message.data == '"start-with-supervision"') startExercise() let json = JSON.parse(message.data)
if (json && json.eventName == 'start-with-supervision') startExercise()
}) })
} }
}) })

Loading…
Cancel
Save