console.log("#######################################") console.log("### SERVEUR DE MESSAGE EVENEMENTS ###") console.log("#######################################") // public let connectedUsers = []; // Connexion au serveur d'evenements var idUser = ; eventServer = new WebSocket("wss://events.iscparis.com/WSS-EVENTS/"); // Event de connexion : Envoi des infos d'identification eventServer.onopen = function() { console.log("####### ON OPEN") var authElements = { userData: idUser, enEntretient: false } eventServer.send(JSON.stringify(authElements)); console.log("####### AUTH SENT") } function updateAuth(enEntretient) { console.log("####### updateAuth") var authElements = { userData: idUser, enEntretient: enEntretient } eventServer.send(JSON.stringify(authElements)); console.log("####### UPDATED AUTH SENT") } // Event de réception de message eventServer.onmessage = function (event) { console.log("####### ON MESSAGE") console.log(event.data); var message = jQuery.parseJSON(event.data); switch (message.req) { case 'inviteToOral': notifOralInvite(message) break; case 'getConnected': receiveConnected(message) break; } } function notifOralInvite(message) { console.log("####### notifOralInvite") } function sendInviteToOral(idUserToInvite, idStand) { console.log("####### sendInviteToOral") var message = { req: "inviteToOral", idUserToInvite: idUserToInvite, idStand: idStand } eventServer.send(JSON.stringify(message)); } function sendGetConnected() { console.log("####### sendGetConnected") var message = { req: "getConnected", returnUserId: idUser } eventServer.send(JSON.stringify(message)); } function sendGetEnEntretien() { console.log("####### sendGetEnEntretien") var message = { req: "getEnEntretien", returnUserId: idUser } eventServer.send(JSON.stringify(message)); } function receiveConnected(message) { console.log("####### receiveConnected") connectedUsers = message.lst; if (typeof receiveConnectedCallback === 'function') { receiveConnectedCallback(); } }