session Id to distinguish participants without player name

citations
Fabien Benetou 9 months ago
parent 20dca36947
commit 898464c29b
  1. 6
      index.html

@ -98,11 +98,12 @@ function manualAnimate(selector="#biggu"){
) )
} }
let sessionId = self.crypto.randomUUID()
// 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, eventData, server='https://biggu-backend-collab.glitch.me/'){ function shareLiveEvent(eventName, eventData, server='https://biggu-backend-collab.glitch.me/'){
if (!eventName) return if (!eventName) return
let data = {} let data = { eventName, sessionId }
data.eventName = eventName
if (eventData) data.eventData = eventData if (eventData) data.eventData = eventData
let playername = AFRAME.utils.getUrlParameter('playername') let playername = AFRAME.utils.getUrlParameter('playername')
if (playername) data.playername = playername if (playername) data.playername = playername
@ -197,6 +198,7 @@ AFRAME.registerComponent('start-with-supervision', {
const server='https://biggu-backend-collab.glitch.me' const server='https://biggu-backend-collab.glitch.me'
// CORS enabled needed // CORS enabled needed
const source = new EventSource(server+'/events'); const source = new EventSource(server+'/events');
shareLiveEvent('connected')
source.addEventListener('message', message => { source.addEventListener('message', message => {
console.log('Got', message); console.log('Got', message);

Loading…
Cancel
Save