Stable joining with dummy commands sent on timeouts

This commit is contained in:
Logan Cusano
2024-01-19 23:57:03 -05:00
parent 4a0b1004d2
commit 4ac95f5325
9 changed files with 301 additions and 90 deletions

View File

@@ -1,6 +1,7 @@
import { io } from "socket.io-client";
import { connectToChannel, initDiscordBotClient, getVoiceChannelFromID } from '../discordAudioBot/dab.mjs';
export function initSocketConnection() {
export function initSocketConnection(localNodeConfig) {
const serverEndpoint = `http://${localNodeConfig.serverIp}:${localNodeConfig.serverPort}` || 'http://localhost:3000'; // Adjust the server endpoint
const socket = io.connect(serverEndpoint);
@@ -8,14 +9,26 @@ export function initSocketConnection() {
return socket;
}
export function initSocketListeners(socket){
export function initSocketListeners(socket, localNodeConfig) {
socket.on('connect', () => {
console.log('Connected to the server');
logIntoServer(socket);
logIntoServer(socket, localNodeConfig.node);
});
socket.on('node-join', (joinData) => {
socket.on('node-join', async (joinData) => {
console.log("Join requested: ", joinData)
// TODO - Implement logic to control OP25 for the requested channel
// Join the requested channel with the requested ID
initDiscordBotClient(joinData.clientID, client => {
console.log("Client:", client);
getVoiceChannelFromID(client, joinData.channelID).then(vc => {
console.log("Voice Channel:", vc);
console.log("Voice Channel Guild:", vc.Guild);
const connection = connectToChannel(vc);
})
});
console.log("All done?");
});
socket.on('node-leave', () => {