Init Commit
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
This commit is contained in:
37
client/modules/socketClient.mjs
Normal file
37
client/modules/socketClient.mjs
Normal file
@@ -0,0 +1,37 @@
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user