Server
- Working init discord bot
- Modular events and commands
- Has access to the socket server
- Working init socket server
- Need to work on getting access to discord bot
- Working init web server
Currently working on breaking out the init of the socket server
Client
- Working init socket client
Currently working on the discord bot to join voice channels
37 lines
946 B
JavaScript
37 lines
946 B
JavaScript
import { io } from "socket.io-client";
|
|
|
|
export function initSocketConnection() {
|
|
const serverEndpoint = `http://${localNodeConfig.serverIp}:${localNodeConfig.serverPort}` || 'http://localhost:3000'; // Adjust the server endpoint
|
|
|
|
const socket = io.connect(serverEndpoint);
|
|
|
|
return socket;
|
|
}
|
|
|
|
export function initSocketListeners(socket){
|
|
socket.on('connect', () => {
|
|
console.log('Connected to the server');
|
|
logIntoServer(socket);
|
|
});
|
|
|
|
socket.on('node-join', (joinData) => {
|
|
console.log("Join requested: ", joinData)
|
|
});
|
|
|
|
socket.on('node-leave', () => {
|
|
console.log("Leave requested");
|
|
});
|
|
|
|
socket.on('disconnect', () => {
|
|
console.log('Disconnected from the server');
|
|
});
|
|
|
|
}
|
|
|
|
export function logIntoServer(socket, nodeData) {
|
|
socket.emit("node-login", nodeData);
|
|
}
|
|
|
|
export function sendNodeUpdate(socket, nodeData) {
|
|
socket.emit('node-update', nodeData);
|
|
} |