0

Use ISO date strings. Make random delays longer.

This commit is contained in:
Gabe Kangas 2020-09-28 21:39:56 -07:00
parent 1a477de89a
commit 6a0e8deae3

View File

@ -18,12 +18,12 @@ var availableMessages = messages.slice();
const WebSocket = require('ws'); const WebSocket = require('ws');
const ws = new WebSocket('ws://localhost:8080/entry', { const ws = new WebSocket('wss://watch.owncast.online/entry', {
origin: 'http://localhost:8080', origin: 'http://watch.owncast.online',
}); });
ws.on('open', function open() { ws.on('open', function open() {
setTimeout(sendMessage, 4000); setTimeout(sendMessage, 15000);
}); });
ws.on('error', function incoming(data) { ws.on('error', function incoming(data) {
@ -48,12 +48,12 @@ function sendMessage() {
id: id, id: id,
type: 'CHAT', type: 'CHAT',
visible: true, visible: true,
timestamp: new Date().toString(), timestamp: new Date().toISOString(),
}; };
ws.send(JSON.stringify(testMessage)); ws.send(JSON.stringify(testMessage));
const nextMessageTimeout = (Math.floor(Math.random() * (15 - 3)) + 3) * 1000; const nextMessageTimeout = (Math.floor(Math.random() * (25 - 10)) + 10) * 1000;
setTimeout(sendMessage, nextMessageTimeout); setTimeout(sendMessage, nextMessageTimeout);
} }