snapshot of https://github.com/jitsi/jitsi-meet.git @ fd1749dd28f4138aa80234fc7f311b19aaffa0e7 (2026-09-15)
This commit is contained in:
63
resources/waiting-queue/examples/visitor.js
Normal file
63
resources/waiting-queue/examples/visitor.js
Normal file
@@ -0,0 +1,63 @@
|
||||
const token = 'JWT_TOKEN_GOES_HERE'
|
||||
|
||||
const stompClient = new StompJs.Client({
|
||||
brokerURL: 'ws://localhost:8060/waiting-queue/visitor/websocket',
|
||||
});
|
||||
|
||||
stompClient.onWebSocketError = (error) => {
|
||||
console.error('Error with websocket', error);
|
||||
};
|
||||
|
||||
stompClient.onStompError = (frame) => {
|
||||
console.error('Broker reported error: ' + frame.headers['message']);
|
||||
console.error('Additional details: ' + frame.body);
|
||||
};
|
||||
|
||||
function setConnected(connected) {
|
||||
$("#connect").prop("disabled", connected);
|
||||
$("#disconnect").prop("disabled", !connected);
|
||||
if (connected) {
|
||||
$("#conversation").show();
|
||||
}
|
||||
else {
|
||||
$("#conversation").hide();
|
||||
}
|
||||
$("#messages").html("");
|
||||
}
|
||||
|
||||
function connect(conference) {
|
||||
console.log("Connecting to conference " + conference);
|
||||
|
||||
headers = {
|
||||
Authorization: 'Bearer ' + token
|
||||
};
|
||||
|
||||
stompClient.connectHeaders = headers;
|
||||
|
||||
stompClient.onConnect = (frame) => {
|
||||
setConnected(true);
|
||||
console.log('Connected: ' + frame);
|
||||
|
||||
stompClient.subscribe('/secured/conference/visitor/topic.' + conference, (message) => {
|
||||
showMessage(message.body);
|
||||
}, headers);
|
||||
};
|
||||
|
||||
stompClient.activate();
|
||||
}
|
||||
|
||||
function disconnect() {
|
||||
stompClient.deactivate();
|
||||
setConnected(false);
|
||||
console.log("Disconnected");
|
||||
}
|
||||
|
||||
function showMessage(message) {
|
||||
$("#messages").append("<tr><td>" + message + "</td></tr>");
|
||||
}
|
||||
|
||||
$(function () {
|
||||
$("form").on('submit', (e) => e.preventDefault());
|
||||
$( "#connect" ).click(() => connect($("#conference").val()));
|
||||
$( "#disconnect" ).click(() => disconnect());
|
||||
});
|
||||
Reference in New Issue
Block a user