Files
P42_UI/app/libs/Bus/rendezVous/MBRendezVous.js
T
2025-08-27 07:03:09 +00:00

90 lines
2.3 KiB
JavaScript

'use strict'
/**
* @category MyEic
* @subcategory Libraries
*/
class MBRendezVous {
/**
*
* @param {*} appctrl
*/
constructor(appctrl){
if(!app.MessageBus) return
this.activeMeetChans = {}
this.myUserNotifChan = app.config.messageBus.userNotifChan.replace(/\{uid\}/g, app.User.identity.uuid)
app.MessageBus.addBusListener(
'rendezVous',
[ this.myUserNotifChan ],
this.onRendezVousRequest.bind(this)
)
}
/**
*
* @param {*} chan
* @param {*} payload
* @param {*} sender
*/
async onRendezVousRequest(chan, payload, sender){
if(! await this.userConfirmation(sender, payload.userMessage)) return
let rdvzchan = payload.chanPrefix + crypto.randomUUID()
//this.activeMeetChans[] = chan
}
/**
*
* @param {*} sender
* @param {*} userMessage
*/
async userConfirmation(sender, userMessage){
let options = {
title: 'Connexion request',
message: `<p>The user <b>${sender}</b> invites you to ${userMessage}.</p>
`,
cancelLabel: 'Refuse',
okLabel: 'Accept',
severity: 'danger',
okPromise: () => new Promise((ok,ko)=>ok())
}
await this.mainCtrl.loadContent('templates/dialogs/ConfirmDialog', options, options)
/*
let result = await this.mainView.confirmDialog({
title: 'Connexion request',
message: `<p>The user <b>${sender}</b> invites you to ${userMessage}.</p>
`,
cancelLabel: 'Refuse',
okLabel: 'Accept',
severity: 'danger',
okPromise: () => new Promise((ok,ko)=>ok())
})
if(result) {
console.log('you said YES')
}
*/
}
/**
*
* @param {*} hisUid
* @param {*} userMessage
* @param {*} timeout
* @returns {Promise}
*/
getRendezVousChan(hisUid, userMessage, timeout){
if(!app.MessageBus) return(
new Promise((resolve, reject) => reject('Cannot rendez-vous without messageBus !'))
)
return(
new Promise((resolve, reject) => {
})
)
}
}
app.registerClass('MBRendezVous', MBRendezVous);