mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-25 21:39:21 +00:00
Notify server when joining call
This commit is contained in:
parent
51dcef4565
commit
f3466a98e0
@ -14,46 +14,59 @@ class CallWindow extends CustomEvents {
|
|||||||
*/
|
*/
|
||||||
constructor(conv) {
|
constructor(conv) {
|
||||||
super()
|
super()
|
||||||
|
this.conv = conv;
|
||||||
this.construct(conv);
|
this.construct(conv);
|
||||||
}
|
}
|
||||||
|
|
||||||
async construct(conv) {
|
async construct(conv) {
|
||||||
// Check if calls target exists or not
|
|
||||||
if(!byId("callsTarget"))
|
try {
|
||||||
createElem2({
|
// Check if calls target exists or not
|
||||||
appendTo: byId("wrapper"),
|
if(!byId("callsTarget"))
|
||||||
|
createElem2({
|
||||||
|
appendTo: byId("wrapper"),
|
||||||
|
type: "div",
|
||||||
|
id: "callsTarget",
|
||||||
|
})
|
||||||
|
|
||||||
|
this.conv = conv;
|
||||||
|
|
||||||
|
this.rootEl = createElem2({
|
||||||
|
appendTo: byId("callsTarget"),
|
||||||
type: "div",
|
type: "div",
|
||||||
id: "callsTarget",
|
class: "call-window"
|
||||||
})
|
})
|
||||||
|
|
||||||
this.conv = conv;
|
|
||||||
|
|
||||||
this.rootEl = createElem2({
|
|
||||||
appendTo: byId("callsTarget"),
|
// Construct head
|
||||||
type: "div",
|
this.windowHead = createElem2({
|
||||||
class: "call-window"
|
appendTo: this.rootEl,
|
||||||
})
|
type: "div",
|
||||||
|
class: "head",
|
||||||
|
innerHTML: "<i class='fa fa-phone'></i>" +
|
||||||
|
await getConvName(conv) +
|
||||||
|
" <span class='pull-right'></span>"
|
||||||
|
})
|
||||||
|
|
||||||
|
// Close button
|
||||||
// Construct head
|
this.closeButton = createElem2({
|
||||||
this.windowHead = createElem2({
|
appendTo: this.windowHead.querySelector(".pull-right"),
|
||||||
appendTo: this.rootEl,
|
type: "a",
|
||||||
type: "div",
|
innerHTML: "<i class='fa fa-times'></i>",
|
||||||
class: "head",
|
onclick: () => this.Close()
|
||||||
innerHTML: "<i class='fa fa-phone'></i>" +
|
})
|
||||||
await getConvName(conv) +
|
|
||||||
" <span class='pull-right'></span>"
|
|
||||||
})
|
|
||||||
|
|
||||||
// Close button
|
this.makeWindowDraggable();
|
||||||
this.closeButton = createElem2({
|
|
||||||
appendTo: this.windowHead.querySelector(".pull-right"),
|
|
||||||
type: "a",
|
|
||||||
innerHTML: "<i class='fa fa-times'></i>",
|
|
||||||
onclick: () => this.Close()
|
|
||||||
})
|
|
||||||
|
|
||||||
this.makeWindowDraggable()
|
// Join the call
|
||||||
|
await ws("calls/join", {
|
||||||
|
convID: this.conv.ID
|
||||||
|
})
|
||||||
|
|
||||||
|
} catch(e) {
|
||||||
|
console.error(e)
|
||||||
|
notify("Could not initialize call!", "danger");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -131,9 +144,14 @@ class CallWindow extends CustomEvents {
|
|||||||
* @param {boolean} propagate Set to true to propagate
|
* @param {boolean} propagate Set to true to propagate
|
||||||
* the event
|
* the event
|
||||||
*/
|
*/
|
||||||
Close(propagate = true) {
|
async Close(propagate = true) {
|
||||||
this.rootEl.remove();
|
this.rootEl.remove();
|
||||||
|
|
||||||
|
// Leave the call
|
||||||
|
await ws("calls/leave", {
|
||||||
|
convID: this.conv.ID
|
||||||
|
})
|
||||||
|
|
||||||
if(propagate)
|
if(propagate)
|
||||||
this.emitEvent("close");
|
this.emitEvent("close");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user