mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-10 08:39:34 +00:00
small responsiveness improvements
broadcast every change
This commit is contained in:
@@ -73,6 +73,14 @@ class EventTimer extends Timer {
|
|||||||
this.io.emit('timer', this.getObject());
|
this.io.emit('timer', this.getObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// broadcast state
|
||||||
|
broadcastState() {
|
||||||
|
this.io.emit('timer', this.getObject());
|
||||||
|
this.io.emit('playstate', this.playState);
|
||||||
|
this.io.emit('selected-id', this.selectedEventId);
|
||||||
|
this.io.emit('titles', this.titles);
|
||||||
|
}
|
||||||
|
|
||||||
// broadcast message
|
// broadcast message
|
||||||
broadcastThis(address, payload) {
|
broadcastThis(address, payload) {
|
||||||
this.io.emit(address, payload);
|
this.io.emit(address, payload);
|
||||||
@@ -109,11 +117,14 @@ class EventTimer extends Timer {
|
|||||||
else if (payload === 'next') this.next();
|
else if (payload === 'next') this.next();
|
||||||
else if (payload === 'reload') this.reload();
|
else if (payload === 'reload') this.reload();
|
||||||
else if (payload === 'unload') this.unload();
|
else if (payload === 'unload') this.unload();
|
||||||
|
|
||||||
// Not yet implemented
|
// Not yet implemented
|
||||||
// else if (payload === 'roll') this.roll();
|
// else if (payload === 'roll') this.roll();
|
||||||
|
|
||||||
this.broadcastThis('playstate', this.playState);
|
this.broadcastThis('playstate', this.playState);
|
||||||
this.broadcastThis('selected-id', this.selectedEventId);
|
this.broadcastThis('selected-id', this.selectedEventId);
|
||||||
this.broadcastThis('titles', this.titles);
|
this.broadcastThis('titles', this.titles);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*******************************************/
|
/*******************************************/
|
||||||
@@ -160,11 +171,18 @@ class EventTimer extends Timer {
|
|||||||
/*** HANDLE NEW CONNECTION ***/
|
/*** HANDLE NEW CONNECTION ***/
|
||||||
/*** --------------------- ***/
|
/*** --------------------- ***/
|
||||||
/*******************************/
|
/*******************************/
|
||||||
|
// keep track of connections
|
||||||
this._numClients++;
|
this._numClients++;
|
||||||
console.log(
|
console.log(
|
||||||
`EventTimer: ${this._numClients} Clients with new connection: ${socket.id}`
|
`EventTimer: ${this._numClients} Clients with new connection: ${socket.id}`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// send state
|
||||||
|
socket.emit('timer', this.getObject());
|
||||||
|
socket.emit('playstate', this.playState);
|
||||||
|
socket.emit('selected-id', this.selectedEventId);
|
||||||
|
socket.emit('titles', this.titles);
|
||||||
|
|
||||||
/********************************/
|
/********************************/
|
||||||
/*** HANDLE DISCONNECT USER ***/
|
/*** HANDLE DISCONNECT USER ***/
|
||||||
/*** ---------------------- ***/
|
/*** ---------------------- ***/
|
||||||
@@ -409,59 +427,35 @@ class EventTimer extends Timer {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
set presenterText(text) {
|
start() {
|
||||||
this.presenter.text = text;
|
// call super
|
||||||
|
super.start();
|
||||||
|
|
||||||
|
// broadcast current state
|
||||||
|
this.broadcastState();
|
||||||
}
|
}
|
||||||
|
|
||||||
set presenterVisible(state) {
|
pause() {
|
||||||
this.presenter.visible = state;
|
// call super
|
||||||
|
super.pause();
|
||||||
|
|
||||||
|
// broadcast current state
|
||||||
|
this.broadcastState();
|
||||||
}
|
}
|
||||||
|
|
||||||
set publicText(text) {
|
stop() {
|
||||||
this.public.text = text;
|
// call super
|
||||||
}
|
super.stop();
|
||||||
|
|
||||||
set publicVisible(state) {
|
// broadcast current state
|
||||||
this.public.visible = state;
|
this.broadcastState();
|
||||||
}
|
|
||||||
|
|
||||||
set lowerText(text) {
|
|
||||||
this.lower.text = text;
|
|
||||||
}
|
|
||||||
|
|
||||||
set lowerVisible(state) {
|
|
||||||
this.lower.visible = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
get presenter() {
|
|
||||||
return this.presenter;
|
|
||||||
}
|
|
||||||
|
|
||||||
get public() {
|
|
||||||
return this.public;
|
|
||||||
}
|
|
||||||
|
|
||||||
get lower() {
|
|
||||||
return this.lower;
|
|
||||||
}
|
|
||||||
|
|
||||||
get titles() {
|
|
||||||
return this.titles;
|
|
||||||
}
|
|
||||||
|
|
||||||
getEventData() {}
|
|
||||||
|
|
||||||
get events() {
|
|
||||||
return this._eventList;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Torbjorn: is this a good idea?
|
|
||||||
set events(events) {
|
|
||||||
this._eventList = events;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
goto(eventIndex) {
|
goto(eventIndex) {
|
||||||
this.loadEvent(eventIndex);
|
this.loadEvent(eventIndex);
|
||||||
|
|
||||||
|
// broadcast current state
|
||||||
|
this.broadcastState();
|
||||||
}
|
}
|
||||||
|
|
||||||
roll() {
|
roll() {
|
||||||
@@ -483,6 +477,9 @@ class EventTimer extends Timer {
|
|||||||
|
|
||||||
if (gotoEvent === this.selectedEvent) return;
|
if (gotoEvent === this.selectedEvent) return;
|
||||||
this.goto(gotoEvent);
|
this.goto(gotoEvent);
|
||||||
|
|
||||||
|
// broadcast current state
|
||||||
|
this.broadcastState();
|
||||||
}
|
}
|
||||||
|
|
||||||
next() {
|
next() {
|
||||||
@@ -502,6 +499,9 @@ class EventTimer extends Timer {
|
|||||||
|
|
||||||
if (gotoEvent === this.selectedEvent) return;
|
if (gotoEvent === this.selectedEvent) return;
|
||||||
this.goto(gotoEvent);
|
this.goto(gotoEvent);
|
||||||
|
|
||||||
|
// broadcast current state
|
||||||
|
this.broadcastState();
|
||||||
}
|
}
|
||||||
|
|
||||||
unload() {
|
unload() {
|
||||||
@@ -516,11 +516,20 @@ class EventTimer extends Timer {
|
|||||||
|
|
||||||
// reset selected
|
// reset selected
|
||||||
this._resetSelection();
|
this._resetSelection();
|
||||||
|
|
||||||
|
// broadcast current state
|
||||||
|
this.broadcastState();
|
||||||
}
|
}
|
||||||
|
|
||||||
reload() {
|
reload() {
|
||||||
this._resetTimers();
|
// reload data
|
||||||
|
this.loadEvent(this.selectedEvent);
|
||||||
|
|
||||||
|
// reset playstate
|
||||||
this.state = 'pause';
|
this.state = 'pause';
|
||||||
|
|
||||||
|
// broadcast current state
|
||||||
|
this.broadcastState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -119,14 +119,11 @@ class Timer {
|
|||||||
return Timer.toSeconds(this.current);
|
return Timer.toSeconds(this.current);
|
||||||
}
|
}
|
||||||
|
|
||||||
get playState() {
|
|
||||||
return this.state;
|
|
||||||
}
|
|
||||||
|
|
||||||
// playback
|
// playback
|
||||||
start() {
|
start() {
|
||||||
// do we need to change
|
// do we need to change
|
||||||
if (this.state === 'start') return;
|
if (this.state === 'start') return;
|
||||||
|
else if (this.duration === 0) return;
|
||||||
else if (this.startedAt == null) {
|
else if (this.startedAt == null) {
|
||||||
const now = this._getCurrentTime();
|
const now = this._getCurrentTime();
|
||||||
this._startedAt = now;
|
this._startedAt = now;
|
||||||
@@ -146,6 +143,8 @@ class Timer {
|
|||||||
// do we need to change
|
// do we need to change
|
||||||
if (this.state === 'pause') return;
|
if (this.state === 'pause') return;
|
||||||
|
|
||||||
|
else if (this.duration === 0) return;
|
||||||
|
|
||||||
// update pause time
|
// update pause time
|
||||||
this._pausedAt = this._getCurrentTime();
|
this._pausedAt = this._getCurrentTime();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user