Compare commits

...

5 Commits

Author SHA1 Message Date
2175a55a61 Added prefix, port, host 2025-04-11 17:39:53 +02:00
e620f2532d Merge remote-tracking branch 'int/dev' into dev 2025-04-11 14:45:44 +02:00
90115079a3 Merge remote-tracking branch 'int/dev' into dev 2025-04-11 12:35:31 +02:00
fdcb58493a Typo 2025-04-10 10:51:54 +02:00
a05656efff Documentation 2025-04-10 10:42:17 +02:00
4 changed files with 26 additions and 12 deletions

View File

@@ -2,10 +2,14 @@
# Install: # Install:
1. git clone it 1. git clone it
2. you need nodeJS / npm or bun 2. you need nodeJS / npm or [bun](https://bun.sh/docs/installation)
3. `npm install` or `bun i` 3. `npm install` or `bun i`
4. rename config.js.sample to config.js 4. rename config.js.sample to config.js
5. adjust config.js to your local MQTT-Broker 5. adjust config.js to your local MQTT-Broker
6. ` node ./mqtt.js` or `bun ./mqtt.js` 6. ` node ./mqtt.js` or `bun ./mqtt.js`
7. Point browser to localhost:8000 7. Point browser to localhost:8000
8. Enjoy streaming 8. Enjoy streaming
# Prerequisites:
* MQTT Server (`apt install mosquitto` or docker-mosquitto)
* MQTT-Streaming at wavelog enabled (`config.php`-switch: `$config['mqtt_server']='your_mosquitto_server';`)

View File

@@ -2,8 +2,11 @@ const config = {
mqttserver: { mqttserver: {
host: "mqtt://[your mqtt-server here]" host: "mqtt://[your mqtt-server here]"
}, },
prefix: "",
whitelist_url: "https://laber", whitelist_url: "https://laber",
whitelist_enabled: false whitelist_enabled: false,
webport: 8000,
webbind:"127.0.0.1"
}; };
module.exports = config; module.exports = config;

View File

@@ -1,10 +1,9 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<base href="/">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="/jquery/jquery.min.js"></script> <style type="text/css">
<script src="/socket.io/socket.io.js"></script>
<style type="text/css" rel="stylesheet">
#mqtt{ border: 1px solid #444; overflow-x:hidden; overflow-y:auto; background-color:#333; color: #EEE; text-shadow:#000 0 0 2px; height: 400px; padding: 10px; font-size:12px; line-height:20px;} #mqtt{ border: 1px solid #444; overflow-x:hidden; overflow-y:auto; background-color:#333; color: #EEE; text-shadow:#000 0 0 2px; height: 400px; padding: 10px; font-size:12px; line-height:20px;}
.monospace{font-family: Monaco,"Bitstream Vera Sans Mono","Lucida Console",Terminal,monospace;} .monospace{font-family: Monaco,"Bitstream Vera Sans Mono","Lucida Console",Terminal,monospace;}
.selection::selection , .selection *::selection{background: #EEE;color:#000;border-color:#000; text-shadow:#fff 0 0 2px;} .selection::selection , .selection *::selection{background: #EEE;color:#000;border-color:#000; text-shadow:#fff 0 0 2px;}
@@ -46,6 +45,14 @@
</tbody> </tbody>
</table> </table>
<script type="text/javascript"> <script type="text/javascript">
const base = document.querySelector('base');
if (base) {
base.href = window.location.pathname;
}
document.write(`<script src="${base.href}/jquery/jquery.min.js"><\/script>`);
document.write(`<script src="${base.href}/socket.io/socket.io.js"><\/script>`);
</script>
<script type="text/javascript" defer>
(function() { (function() {
const queryString = window.location.search; const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString); const urlParams = new URLSearchParams(queryString);
@@ -53,7 +60,7 @@
const tableBody = document.getElementById('messagesTable').querySelector('tbody'); const tableBody = document.getElementById('messagesTable').querySelector('tbody');
var lines = 0; var lines = 0;
var buffer = $('#mqtt'); var buffer = $('#mqtt');
var socket = io.connect("/"); // http://localhost:8000"); var socket = io.connect({ path: window.location.pathname+"/socket.io" }); // http://localhost:8000");
socket.on('connect', function() { socket.on('connect', function() {
console.log('Connected to:', socket.host); console.log('Connected to:', socket.host);
}); });

12
mqtt.js
View File

@@ -6,13 +6,13 @@ const path = require('path');
const express = require('express'); const express = require('express');
const app = express(); // http-express framework laden (macht routing, etc.) const app = express(); // http-express framework laden (macht routing, etc.)
const http = require('http').Server(app); // http-server module laden const http = require('http').Server(app); // http-server module laden
const io = require('socket.io')(http); // socket.io einbinden const io = require('socket.io')(http, {path: `${config.prefix}/socket.io`,}); // socket.io einbinden
var whitelist=[]; var whitelist=[];
app.use('/jquery', express.static(path.join(__dirname, 'node_modules', 'jquery', 'dist'))); app.use(config.prefix+'/jquery', express.static(path.join(__dirname, 'node_modules', 'jquery', 'dist')));
app.get('/', (req, res) => { // Routing fuer index.html app.get(config.prefix+'/', (req, res) => {
res.sendFile(__dirname + '/index.html'); // index.html rauspusten res.sendFile(__dirname + '/index.html');
}); });
const mqttC=mqtt.connect(mqttserver); const mqttC=mqtt.connect(mqttserver);
@@ -116,8 +116,8 @@ const dinmin = (timestamp) => {
function startup() { function startup() {
getWhitelist(); getWhitelist();
http.listen(8000,'127.0.0.1', () => { // Webserver starten http.listen(config.webport,'127.0.0.1', () => { // Webserver starten
console.log(`Socket.IO server running at http://localhost:8000/`); // debug console.log(`Socket.IO server running at http://${config.webbind}:${config.webport}`); // debug
}); });
const intervalID = setInterval(getWhitelist,5*60*1000); const intervalID = setInterval(getWhitelist,5*60*1000);
} }