mirror of
https://github.com/fishtank-dashboard/fishtank-dashboard.git
synced 2026-05-02 05:22:03 -04:00
added clip trimming, chat popout + minor changes
This commit is contained in:
committed by
GitHub
parent
1c63a3c95f
commit
ffcdd43004
18
server.js
18
server.js
@@ -76,15 +76,12 @@ function sendBinary(buf) {
|
||||
|
||||
function sendAuthFrame() {
|
||||
if (!ftToken) {
|
||||
console.log('[WS] No token — connecting unauthenticated (limited events)');
|
||||
return;
|
||||
}
|
||||
console.log('[WS] Sending auth frame with token');
|
||||
sendBinary(buildAuthFrame(ftToken));
|
||||
}
|
||||
|
||||
function sendSubscriptions() {
|
||||
console.log('[WS] Subscribing to chat:presence and presence');
|
||||
sendBinary(buildSubscribeFrame('chat:presence'));
|
||||
sendBinary(buildSubscribeFrame('presence'));
|
||||
}
|
||||
@@ -203,7 +200,6 @@ function mpDecode(buf, offset = 0) {
|
||||
// negative fixint
|
||||
if ((b & 0xe0) === 0xe0) return [b - 256, offset];
|
||||
|
||||
console.log(`[MSGPACK] Unknown type byte: 0x${b.toString(16)} at offset ${offset-1}`);
|
||||
return [null, offset];
|
||||
}
|
||||
|
||||
@@ -232,20 +228,16 @@ function handleBinaryFrame(buf) {
|
||||
|
||||
// Skip internal room/presence bookkeeping
|
||||
if (eventName === 'chat:room') {
|
||||
console.log(`[WS] Room assigned: ${JSON.stringify(eventPayload)}`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (eventName !== 'chat:message') {
|
||||
console.log(`
|
||||
[WS EVENT] "${eventName}" ${JSON.stringify(eventPayload).slice(0, 160)}`);
|
||||
}
|
||||
broadcast({ _ft: 'event', event: eventName, data: eventPayload });
|
||||
return;
|
||||
}
|
||||
|
||||
// Anything else — log raw for debugging
|
||||
console.log(`[WS PACKET] type=${type} data=${JSON.stringify(data).slice(0, 200)}`);
|
||||
|
||||
} catch(e) {
|
||||
console.log('[WS] Binary decode error:', e.message, e.stack);
|
||||
@@ -296,7 +288,6 @@ function connectFishtankWS(token) {
|
||||
// Server ping — pong back
|
||||
if (msg === '2') { ftSocket.send('3'); return; }
|
||||
|
||||
console.log(`[WS TEXT] ${msg.slice(0, 200)}`);
|
||||
});
|
||||
|
||||
ftSocket.on('close', (code, reason) => {
|
||||
@@ -376,6 +367,15 @@ const server = http.createServer((req, res) => {
|
||||
}); return;
|
||||
}
|
||||
|
||||
if (parsed.pathname === '/chat') {
|
||||
const file = path.join(__dirname, 'chat-popout.html');
|
||||
fs.readFile(file, (err, data) => {
|
||||
if (err) { res.writeHead(404); res.end('Chat not found'); return; }
|
||||
res.writeHead(200, { 'Content-Type': 'text/html' });
|
||||
res.end(data);
|
||||
}); return;
|
||||
}
|
||||
|
||||
// Token registration from dashboard
|
||||
if (parsed.pathname === '/ws-token' && req.method === 'POST') {
|
||||
let body = '';
|
||||
|
||||
Reference in New Issue
Block a user