Major updates to core
This commit is contained in:
@@ -2,6 +2,7 @@ import express from 'express';
|
||||
import { createServer } from 'node:http';
|
||||
import { Server } from 'socket.io';
|
||||
import morgan from 'morgan';
|
||||
import { nodeLoginWrapper, nodeUpdateWrapper, nodeDisconnectWrapper, nearbySystemsUpdateWraper } from "./socketServerWrappers.mjs";
|
||||
|
||||
export const app = express();
|
||||
export const server = createServer(app);
|
||||
@@ -17,48 +18,21 @@ nodeIo.on('connection', (socket) => {
|
||||
console.log('a user connected', socket.id);
|
||||
|
||||
socket.on('node-login', (data) => {
|
||||
nodeLoginWrapper(data);
|
||||
nodeLoginWrapper(data, socket);
|
||||
})
|
||||
|
||||
socket.on('node-update', (data) => {
|
||||
updateNodeData(data);
|
||||
nodeUpdateWrapper(data.node);
|
||||
nearbySystemsUpdateWraper(data.node.nuid, data.nearbySystems)
|
||||
})
|
||||
|
||||
socket.on('disconnect', () => {
|
||||
console.log('user disconnected');
|
||||
nodeDisconnectWrapper(socket.id);
|
||||
});
|
||||
|
||||
// Test commands
|
||||
setTimeout(() => {
|
||||
const joinData = {
|
||||
'clientID': "MTE5NjAwNTM2ODYzNjExMjk3Nw.GuCMXg.24iNNofNNumq46FIj68zMe9RmQgugAgfrvelEA",
|
||||
'channelID': "367396189529833476",
|
||||
'preset': ""
|
||||
}
|
||||
sendNodeCommand(socket, "node-join", joinData);
|
||||
}, 2500)
|
||||
//setTimeout(() => { sendNodeCommand(socket, "node-leave", {}); }, 3500)
|
||||
});
|
||||
|
||||
function sendNodeCommand(socket, command, data) {
|
||||
// TODO - Check to see if the command exists
|
||||
// TODO - Check to see if the socket is alive?
|
||||
// TODO - Validate the given data
|
||||
socket.emit(command, data);
|
||||
}
|
||||
|
||||
function loginNode() {
|
||||
|
||||
}
|
||||
|
||||
function registerNode() {
|
||||
|
||||
}
|
||||
|
||||
function updateNodeData(data) {
|
||||
console.log("Data update sent by node: ", data);
|
||||
}
|
||||
|
||||
function nodeLoginWrapper(data) {
|
||||
console.log(`Login requested from node: ${data.id}`, data);
|
||||
}
|
||||
// Startup the node server
|
||||
server.listen(3000, () => {
|
||||
console.log('server running at http://localhost:3000');
|
||||
});
|
||||
Reference in New Issue
Block a user