-the counter don't stop
This commit is contained in:
parent
3c58b3bef5
commit
2d95efcaf8
10 changed files with 19 additions and 21 deletions
BIN
backend/backend
BIN
backend/backend
Binary file not shown.
|
@ -13,6 +13,7 @@ import (
|
|||
func (w *Webapp) StartTimer(c *gin.Context) {
|
||||
var msg Message
|
||||
var err error
|
||||
var timer time.Duration
|
||||
|
||||
err = c.ShouldBind(&msg)
|
||||
if err != nil {
|
||||
|
@ -21,15 +22,16 @@ func (w *Webapp) StartTimer(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
w.Stream.Duration, err = time.ParseDuration(msg.Duration)
|
||||
timer, err = time.ParseDuration(msg.Duration)
|
||||
if err != nil {
|
||||
log.Printf("req error: %+v", err)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
w.Stream.Duration = timer
|
||||
w.Stream.Start = true
|
||||
|
||||
log.Printf("start timer %s", w.Stream.Duration)
|
||||
log.Printf("start timer %s - received %s", w.Stream.Duration, msg.Duration)
|
||||
c.JSON(http.StatusOK, w.Stream.Duration)
|
||||
}
|
||||
|
||||
|
|
|
@ -167,9 +167,10 @@ func (stream *PriorityStream) SendPriority(pri []string) {
|
|||
}
|
||||
|
||||
func (stream *PriorityStream) timer() {
|
||||
if stream.Start {
|
||||
timer := time.NewTimer(stream.Duration)
|
||||
for {
|
||||
for {
|
||||
if stream.Start {
|
||||
timer := time.NewTimer(stream.Duration)
|
||||
|
||||
select {
|
||||
case <-timer.C:
|
||||
stream.Start = false
|
||||
|
@ -178,10 +179,10 @@ func (stream *PriorityStream) timer() {
|
|||
Mode: Stop.String(),
|
||||
}
|
||||
stream.Message <- msg
|
||||
return
|
||||
continue
|
||||
default:
|
||||
if len(stream.TotalClients) > 0 {
|
||||
currentTimer := fmt.Sprintf("The Current Time Is %v", formatTime(stream.Duration))
|
||||
currentTimer := fmt.Sprintf("%v", formatTime(stream.Duration))
|
||||
|
||||
msg := Message{
|
||||
Duration: currentTimer,
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"version":"1701787521369"}
|
||||
{"version":"1701788771196"}
|
Binary file not shown.
Binary file not shown.
|
@ -5,17 +5,17 @@
|
|||
<link rel="icon" href="/favicon.png" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<link rel="modulepreload" href="/_app/immutable/entry/start.f942bb89.js">
|
||||
<link rel="modulepreload" href="/_app/immutable/entry/start.44f26591.js">
|
||||
<link rel="modulepreload" href="/_app/immutable/chunks/scheduler.9172086d.js">
|
||||
<link rel="modulepreload" href="/_app/immutable/chunks/singletons.020ac99d.js">
|
||||
<link rel="modulepreload" href="/_app/immutable/entry/app.af53e384.js">
|
||||
<link rel="modulepreload" href="/_app/immutable/chunks/singletons.58002853.js">
|
||||
<link rel="modulepreload" href="/_app/immutable/entry/app.5fcbfdd4.js">
|
||||
<link rel="modulepreload" href="/_app/immutable/chunks/index.c679962e.js">
|
||||
</head>
|
||||
<body data-sveltekit-preload-data="hover">
|
||||
<div style="display: contents">
|
||||
<script>
|
||||
{
|
||||
__sveltekit_1s7z6vk = {
|
||||
__sveltekit_wxhjzu = {
|
||||
base: "",
|
||||
env: {}
|
||||
};
|
||||
|
@ -23,8 +23,8 @@
|
|||
const element = document.currentScript.parentElement;
|
||||
|
||||
Promise.all([
|
||||
import("/_app/immutable/entry/start.f942bb89.js"),
|
||||
import("/_app/immutable/entry/app.af53e384.js")
|
||||
import("/_app/immutable/entry/start.44f26591.js"),
|
||||
import("/_app/immutable/entry/app.5fcbfdd4.js")
|
||||
]).then(([kit, app]) => {
|
||||
kit.start(app, element);
|
||||
});
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -57,6 +57,7 @@
|
|||
}
|
||||
} else if (Msg.mode === 'time') {
|
||||
console.log(`duration: ${Msg.duration}`);
|
||||
min, sec = Msg.duration.split(":");
|
||||
} else if (Msg.mode === 'stop') {
|
||||
console.log(`stop duration: ${Msg.duration}`);
|
||||
end = true;
|
||||
|
@ -95,19 +96,13 @@
|
|||
const res = await fetch(`/api/start`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
duration: "10m0s",
|
||||
duration: "0m25s",
|
||||
mode: 'time'
|
||||
}),
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
console.log(
|
||||
JSON.stringify({
|
||||
duration: "10m0s",
|
||||
mode: 'time'
|
||||
})
|
||||
);
|
||||
console.log(`retval: ${JSON.stringify(res)}`);
|
||||
start = true;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue