mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-10 08:39:34 +00:00
websocket data test
This commit is contained in:
@@ -38,8 +38,11 @@ export default function Editor() {
|
|||||||
console.log('websocket started');
|
console.log('websocket started');
|
||||||
|
|
||||||
socket.on('FromAPI', (data) => {
|
socket.on('FromAPI', (data) => {
|
||||||
setResponse(data);
|
console.log('got date', data);
|
||||||
console.log('websocket stuff', data);
|
});
|
||||||
|
|
||||||
|
socket.on('eventdata', (data) => {
|
||||||
|
console.log('got eventdata', data);
|
||||||
});
|
});
|
||||||
|
|
||||||
return () => socket.disconnect();
|
return () => socket.disconnect();
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
const express = require('express');
|
const express = require('express');
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
const socketIo = require('socket.io');
|
const socketIo = require('socket.io');
|
||||||
|
const sampleData = require('./data/sampleData.js');
|
||||||
|
|
||||||
|
// TODO: implement timer
|
||||||
|
// TODO: - Play / pause
|
||||||
|
|
||||||
const port = process.env.PORT || 4001;
|
const port = process.env.PORT || 4001;
|
||||||
const index = require('./routes/index');
|
const index = require('./routes/index');
|
||||||
@@ -8,8 +12,10 @@ const index = require('./routes/index');
|
|||||||
const app = express();
|
const app = express();
|
||||||
app.use(index);
|
app.use(index);
|
||||||
|
|
||||||
|
// create HTTP server
|
||||||
const server = http.createServer(app);
|
const server = http.createServer(app);
|
||||||
|
|
||||||
|
// initialise socketIO server
|
||||||
const io = socketIo(server, {
|
const io = socketIo(server, {
|
||||||
cors: {
|
cors: {
|
||||||
origin: 'http://localhost:3000',
|
origin: 'http://localhost:3000',
|
||||||
@@ -17,10 +23,12 @@ const io = socketIo(server, {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// transmit
|
||||||
let interval;
|
let interval;
|
||||||
|
|
||||||
io.on('connection', (socket) => {
|
io.on('connection', (socket) => {
|
||||||
console.log('New client connected');
|
console.log('New client connected');
|
||||||
|
socket.emit('eventdata', sampleData);
|
||||||
if (interval) {
|
if (interval) {
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
const dummy = new Date();
|
||||||
|
|
||||||
|
const sampleData = [
|
||||||
|
{
|
||||||
|
id: '1',
|
||||||
|
order: 1,
|
||||||
|
title: 'Is the internet a fad?',
|
||||||
|
subtitle: 'It is',
|
||||||
|
presenter: 'Carlos Valente',
|
||||||
|
timeStart: new Date('October 13, 2014 11:30:00'),
|
||||||
|
timeEnd: new Date('October 13, 2014 11:50:00'),
|
||||||
|
clockStarted: dummy,
|
||||||
|
timerDuration: 60,
|
||||||
|
type: 'event',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 0.4849093424577693,
|
||||||
|
order: 2,
|
||||||
|
timerDuration: 25,
|
||||||
|
type: 'delay',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '2',
|
||||||
|
order: 3,
|
||||||
|
title: 'Is reddit a dictatorship?',
|
||||||
|
subtitle: 'It is',
|
||||||
|
presenter: 'Carlos Valente',
|
||||||
|
timeStart: new Date('October 13, 2014 12:30:00'),
|
||||||
|
timeEnd: new Date('October 13, 2014 12:50:00'),
|
||||||
|
clockStarted: dummy,
|
||||||
|
timerDuration: 60,
|
||||||
|
type: 'event',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '3',
|
||||||
|
order: 4,
|
||||||
|
title: 'Out of words',
|
||||||
|
subtitle: '',
|
||||||
|
presenter: 'Carlos Valente',
|
||||||
|
timeStart: new Date('October 13, 2014 13:30:00'),
|
||||||
|
timeEnd: new Date('October 13, 2014 13:50:00'),
|
||||||
|
clockStarted: dummy,
|
||||||
|
timerDuration: 60,
|
||||||
|
type: 'event',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
module.exports = sampleData;
|
||||||
Reference in New Issue
Block a user