- Add Next.js app structure with base configs, linting, and formatting - Implement LiveKit Meet page, types, and utility functions - Add Docker, Compose, and deployment scripts for backend and token server - Provide E2E and smoke test scaffolding with Puppeteer and Playwright helpers - Include CSS modules and global styles for UI - Add postMessage and studio integration utilities - Update package.json with dependencies and scripts for development and testing
58 lines
1.8 KiB
JavaScript
58 lines
1.8 KiB
JavaScript
import { createRequire } from 'module';
|
|
const require = createRequire(import.meta.url);
|
|
const WebSocket = require('ws');
|
|
|
|
// Usar ws:// por defecto (no-TLS). Puede sobreescribirse con env WSS o WS.
|
|
const DEFAULT_WS = 'ws://browserless.bfzqqk.easypanel.host?token=e2e098863b912f6a178b68e71ec3c58d';
|
|
const DEFAULT_WSS = 'wss://browserless.bfzqqk.easypanel.host?token=e2e098863b912f6a178b68e71ec3c58d';
|
|
|
|
// Prioridad: WSS env var -> WS env var -> DEFAULT_WS
|
|
const url = process.env.WSS || process.env.WS || DEFAULT_WS;
|
|
console.log('Attempting WebSocket URL:', url);
|
|
|
|
let opened = false;
|
|
try{
|
|
const ws = new WebSocket(url, { handshakeTimeout: 15000 });
|
|
|
|
ws.on('open', () => {
|
|
opened = true;
|
|
console.log('EVENT: open');
|
|
// send a simple ping-like frame
|
|
try{
|
|
ws.send(JSON.stringify({ type: 'ping', ts: Date.now() }));
|
|
console.log('Sent ping');
|
|
}catch(e){ console.error('SEND ERROR', e && e.message ? e.message : e); }
|
|
});
|
|
|
|
ws.on('message', (data) => {
|
|
try{
|
|
console.log('EVENT: message', typeof data === 'string' ? data : data.toString());
|
|
}catch(e){ console.log('EVENT: message (binary)'); }
|
|
});
|
|
|
|
ws.on('close', (code, reason) => {
|
|
console.log('EVENT: close', code, reason && reason.toString());
|
|
process.exit(0);
|
|
});
|
|
|
|
ws.on('error', (err) => {
|
|
console.error('EVENT: error', err && err.message ? err.message : err);
|
|
setTimeout(()=>process.exit(1), 500);
|
|
});
|
|
|
|
// safety timeout
|
|
setTimeout(()=>{
|
|
if(!opened){
|
|
console.error('TIMEOUT: did not open connection within 15s');
|
|
try{ ws.terminate(); }catch(e){}
|
|
process.exit(2);
|
|
} else {
|
|
console.log('INFO: connection opened, waiting 8s for messages then close');
|
|
setTimeout(()=>{ try{ ws.close(); }catch(e){} }, 8000);
|
|
}
|
|
}, 15000);
|
|
}catch(e){
|
|
console.error('FATAL:', e && e.message ? e.message : e);
|
|
process.exit(3);
|
|
}
|