mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-22 07:29:08 +00:00
add messages
- overtime - title - finished
This commit is contained in:
@@ -110,12 +110,34 @@ export class EventTimer extends Timer {
|
|||||||
const prev = 'prev';
|
const prev = 'prev';
|
||||||
const next = 'next';
|
const next = 'next';
|
||||||
const reload = 'reload';
|
const reload = 'reload';
|
||||||
|
const finished = 'finished';
|
||||||
|
const time = this.timeTag;
|
||||||
|
// TODO: Should this be boolean?
|
||||||
|
const overtime = this.current > 0 ? 0 : 1;
|
||||||
|
const title = this.titles.titleNow;
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case 'time':
|
case 'time':
|
||||||
// Send Timetag Message
|
// Send Timetag Message
|
||||||
|
this.oscClient.send(add + '/time', time, (err) => {
|
||||||
this.oscClient.send(add, this.timeTag, (err) => {
|
if (err) console.error(err);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 'finished':
|
||||||
|
// Runs when timer reaches 0
|
||||||
|
this.oscClient.send(add, finished, (err) => {
|
||||||
|
if (err) console.error(err);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 'overtime':
|
||||||
|
// Whether timer is negative
|
||||||
|
this.oscClient.send(add + '/overtime', overtime, (err) => {
|
||||||
|
if (err) console.error(err);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 'title':
|
||||||
|
// Send Title of current event
|
||||||
|
this.oscClient.send(add + '/title', title, (err) => {
|
||||||
if (err) console.error(err);
|
if (err) console.error(err);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@@ -163,8 +185,11 @@ export class EventTimer extends Timer {
|
|||||||
// through websockets
|
// through websockets
|
||||||
this.io.emit('timer', this.getObject());
|
this.io.emit('timer', this.getObject());
|
||||||
|
|
||||||
// through OSC
|
// through OSC, only if running
|
||||||
this.sendOSC('time');
|
if (this.state === 'start' || this.state === 'roll') {
|
||||||
|
this.sendOSC('time');
|
||||||
|
this.sendOSC('overtime');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// broadcast state
|
// broadcast state
|
||||||
@@ -189,30 +214,32 @@ export class EventTimer extends Timer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
update() {
|
update() {
|
||||||
// if there is nothing selected, no nothing
|
// if there is nothing selected, do nothing
|
||||||
if (this.selectedEventId == null && this.state !== 'roll') return;
|
if (this.selectedEventId == null && this.state !== 'roll') return;
|
||||||
|
|
||||||
// only implement roll here
|
// only implement roll here
|
||||||
if (this.state !== 'roll') {
|
if (this.state !== 'roll') {
|
||||||
super.update();
|
super.update();
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get current time
|
|
||||||
const now = this._getCurrentTime();
|
|
||||||
this.clock = now;
|
|
||||||
|
|
||||||
if (this.selectedEventId && this.current > 0) {
|
|
||||||
// update timer as usual
|
|
||||||
this.current = this._finishAt - now;
|
|
||||||
} else {
|
} else {
|
||||||
// look for event if none is loaded
|
// get current time
|
||||||
if (this.current <= 0 || this.secondaryTimer <= 0) this.rollLoad();
|
const now = this._getCurrentTime();
|
||||||
|
this.clock = now;
|
||||||
|
|
||||||
// count to next event
|
if (this.selectedEventId && this.current > 0) {
|
||||||
// TODO: replace with proper counter
|
// update timer as usual
|
||||||
if (this.secondaryTimer != null) this.secondaryTimer -= 1000;
|
this.current = this._finishAt - now;
|
||||||
|
} else {
|
||||||
|
// look for event if none is loaded
|
||||||
|
if (this.current <= 0 || this.secondaryTimer <= 0) this.rollLoad();
|
||||||
|
|
||||||
|
// count to next event
|
||||||
|
// TODO: replace with proper counter
|
||||||
|
if (this.secondaryTimer != null) this.secondaryTimer -= 1000;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sendOSC on reaching 0
|
||||||
|
if (this.current === 0 && this.state === 'start') this.sendOSC('finished');
|
||||||
}
|
}
|
||||||
|
|
||||||
_setterManager(action, payload) {
|
_setterManager(action, payload) {
|
||||||
|
|||||||
Reference in New Issue
Block a user