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:
45
client/client.js
Normal file
45
client/client.js
Normal file
@@ -0,0 +1,45 @@
|
||||
import { generateUniqueID } from './modules/baseUtils.mjs';
|
||||
import { updateId } from './modules/updateConfig.mjs';
|
||||
import { ClientNodeConfig } from './modules/clientObjectDefinitions.mjs';
|
||||
import { initSocketConnection, initSocketListeners, sendNodeUpdate } from './modules/socketClient.mjs';
|
||||
|
||||
import dotenv from 'dotenv';
|
||||
dotenv.config()
|
||||
|
||||
var localNodeConfig = new ClientNodeConfig({})
|
||||
|
||||
async function boot() {
|
||||
if (localNodeConfig.node.id === undefined || localNodeConfig.node.id === '' || localNodeConfig.node.id === 0) {
|
||||
// Run the first time boot sequence
|
||||
await firstTimeBoot();
|
||||
}
|
||||
// Initialize the socket connection with the server
|
||||
return initSocketConnection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the first time the client boots on a pc
|
||||
* @returns {any}
|
||||
*/
|
||||
async function firstTimeBoot() {
|
||||
// Generate a new ID for the node
|
||||
localNodeConfig.node.id = generateUniqueID();
|
||||
console.log(`Generated a new unique ID for this node: '${localNodeConfig.node.id}'`);
|
||||
|
||||
// Update the config with the new ID
|
||||
updateId(localNodeConfig.node.id);
|
||||
console.log("Updated the config with the new node ID");
|
||||
// TODO - Create the config file with the ID given and replace the update above
|
||||
|
||||
// TODO - Implement web server so users can update radio systems easily
|
||||
// TODO - Implement logic to check if the presets are set
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
// Boot the client application
|
||||
boot().then((openSocket) => {
|
||||
initSocketListeners(openSocket);
|
||||
//console.log(openSocket, "Open socket");
|
||||
setTimeout(() => {sendNodeUpdate(openSocket);}, 2500);
|
||||
})
|
||||
Reference in New Issue
Block a user