Update PDAB handler
- Move PDAB socket server startup to function - Updated join server wrapper to start the server before opening the python app
This commit is contained in:
@@ -19,6 +19,14 @@ const __dirname = dirname(__filename);
|
|||||||
|
|
||||||
let botCallback;
|
let botCallback;
|
||||||
|
|
||||||
|
export const initDiscordBotClient = (clientId, callback, runPDAB = true) => {
|
||||||
|
botCallback = callback;
|
||||||
|
|
||||||
|
if (runPDAB) launchProcess("python", [join(__dirname, "./pdab/main.py"), process.env.AUDIO_DEVICE_ID, clientId, port], false, join(__dirname, "./pdab"));
|
||||||
|
pdabProcess = true; // TODO - Make this more dynamic
|
||||||
|
}
|
||||||
|
|
||||||
|
export const startPdabSocketServer = () => {
|
||||||
const port = process.env.PDAB_PORT || 3000;
|
const port = process.env.PDAB_PORT || 3000;
|
||||||
|
|
||||||
io.on('connection', (socket) => {
|
io.on('connection', (socket) => {
|
||||||
@@ -38,12 +46,7 @@ io.on('connection', (socket) => {
|
|||||||
server.listen(port, async () => {
|
server.listen(port, async () => {
|
||||||
console.log(`Server is running on port ${port}`);
|
console.log(`Server is running on port ${port}`);
|
||||||
});
|
});
|
||||||
|
return
|
||||||
export const initDiscordBotClient = (clientId, callback, runPDAB = true) => {
|
|
||||||
botCallback = callback;
|
|
||||||
|
|
||||||
if (runPDAB) launchProcess("python", [join(__dirname, "./pdab/main.py"), process.env.AUDIO_DEVICE_ID, clientId, port], false, join(__dirname, "./pdab"));
|
|
||||||
pdabProcess = true; // TODO - Make this more dynamic
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const closePdabSocketServer = () => {
|
export const closePdabSocketServer = () => {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { connectToChannel, leaveVoiceChannel, checkIfConnectedToVC, initDiscordBotClient, requestDiscordUsername, requestDiscordID, requestDiscordClientClose, closePdabSocketServer, setDiscordClientPrsense } from './pdabHandler.mjs';
|
import { connectToChannel, leaveVoiceChannel, checkIfConnectedToVC, initDiscordBotClient, requestDiscordUsername, requestDiscordID, requestDiscordClientClose, closePdabSocketServer, setDiscordClientPrsense, startPdabSocketServer } from './pdabHandler.mjs';
|
||||||
import { openOP25, closeOP25 } from '../op25Handler/op25Handler.mjs';
|
import { openOP25, closeOP25 } from '../op25Handler/op25Handler.mjs';
|
||||||
|
|
||||||
let activeDiscordClient = undefined;
|
let activeDiscordClient = undefined;
|
||||||
@@ -14,6 +14,7 @@ export const joinDiscordVC = async (joinData) => {
|
|||||||
console.log("Checking if there is a client open");
|
console.log("Checking if there is a client open");
|
||||||
if (!await checkIfClientIsOpen()) {
|
if (!await checkIfClientIsOpen()) {
|
||||||
console.log("There is no open client, starting it now");
|
console.log("There is no open client, starting it now");
|
||||||
|
await startPdabSocketServer();
|
||||||
// Open an instance of OP25
|
// Open an instance of OP25
|
||||||
console.log("Starting OP25")
|
console.log("Starting OP25")
|
||||||
openOP25(joinData.system);
|
openOP25(joinData.system);
|
||||||
|
|||||||
Reference in New Issue
Block a user