Update: changes in 3DInput mit WSS
This commit is contained in:
22
3DInput.js
22
3DInput.js
@@ -2,6 +2,7 @@ const fs = require('fs');
|
||||
const https = require('https');
|
||||
const WebSocket = require('ws');
|
||||
const url = require('url');
|
||||
const driverWS = require("./programs/driver");
|
||||
|
||||
const httpsOptions = {
|
||||
"enable": true,
|
||||
@@ -34,6 +35,27 @@ server = https.createServer(httpsOptions, (req, res) => {
|
||||
})
|
||||
});
|
||||
|
||||
// vvvvvvvvvvvvvvvvvvvvv Forward WebSocket: Eigener WSS auf Driver vvvvvvvvvvvvvvvvvvvvvvvv
|
||||
const wssInput = new WebSocket.Server({ noServer: true });
|
||||
const targetServer = process.env.TARGET_SERVER || 'wss://localhost:2095';
|
||||
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
||||
driverWS.setupCommandForwarding(wssInput, targetServer);
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
// Upgrade handler: accept all WebSocket upgrades and forward to the forwarding server (wssInput)
|
||||
server.on('upgrade', (req, socket, head) => {
|
||||
const pathname = url.parse(req.url).pathname;
|
||||
console.log('Upgrade request for', pathname);
|
||||
try {
|
||||
// Forward the upgrade to the forwarding server
|
||||
wssInput.handleUpgrade(req, socket, head, (ws) => {
|
||||
wssInput.emit('connection', ws, req);
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('Upgrade handling error:', err && err.message || err);
|
||||
socket.destroy();
|
||||
}
|
||||
});
|
||||
|
||||
server.listen(10010);
|
||||
console.log("Connect to: https://localhost:10010")
|
||||
|
||||
Reference in New Issue
Block a user