Announce participant joins and leaves

This commit is contained in:
Storm Dragon
2026-05-21 22:42:52 -04:00
parent eae4afb7ce
commit c3a9b05392
2 changed files with 21 additions and 5 deletions
+10 -3
View File
@@ -1876,19 +1876,26 @@ function delUser(id) {
/**
* @param {string} id
* @param {string} kind
* @param {user|null} userinfo
*/
function gotUser(id, kind) {
function gotUser(id, kind, userinfo) {
let username = userinfo && userinfo.username ? userinfo.username : '(anon)';
let isRemote = id !== serverConnection.id;
switch(kind) {
case 'add':
addUser(id, serverConnection.users[id]);
if(userNotificationSoundsReady && id !== serverConnection.id)
if(userNotificationSoundsReady && isRemote) {
localMessage(`${username} joined the hall.`);
playNotificationSound('user-joined');
}
if(Object.keys(serverConnection.users).length == 3)
reconsiderSendParameters();
break;
case 'delete':
if(userNotificationSoundsReady && id !== serverConnection.id)
if(userNotificationSoundsReady && isRemote) {
localMessage(`${username} left the hall.`);
playNotificationSound('user-left');
}
delUser(id);
if(Object.keys(serverConnection.users).length < 3)
scheduleReconsiderParameters();