Feat: Adding GUILDS! #12

Merged
snxraven merged 21 commits from guilds into main 2024-07-07 23:01:33 -04:00
2 changed files with 20 additions and 3 deletions
Showing only changes of commit d423031cfb - Show all commits

19
app.js
View File

@ -351,6 +351,8 @@ function handleIncomingMessage(messageObj) {
peer.write(renameMessage); peer.write(renameMessage);
} }
} }
} }
} }
} else if (messageObj.type === 'guildJoin') { } else if (messageObj.type === 'guildJoin') {
@ -361,7 +363,22 @@ function handleIncomingMessage(messageObj) {
renderGuildList(); renderGuildList();
joinGuild(guildTopic); joinGuild(guildTopic);
} }
} else { } else if (messageObj.type === 'guildRequest') {
const guildTopic = messageObj.guildTopic;
const guild = config.guilds[guildTopic];
if (guild) {
const guildResponseMessage = JSON.stringify({
type: 'guildResponse',
guildData: JSON.stringify({
guildTopic,
guildAlias: guild.alias,
rooms: guild.rooms,
owner: guild.owner
})
});
connection.write(guildResponseMessage);
}
} else {
console.error('Received unknown message type:', messageObj); console.error('Received unknown message type:', messageObj);
} }
} }

View File

@ -185,7 +185,7 @@
joinGuildBtn.addEventListener('click', async (event) => { joinGuildBtn.addEventListener('click', async (event) => {
const guildTopic = document.getElementById('join-guild-topic').value.trim(); const guildTopic = document.getElementById('join-guild-topic').value.trim();
if (guildTopic) { if (guildTopic) {
await processGuild(guildTopic); await joinGuildRequest(guildTopic);
} }
}); });
@ -254,4 +254,4 @@
} }
</script> </script>
</body> </body>
</html> </html>