diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-05-31 20:53:12 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2023-05-31 20:54:08 +0200 |
| commit | 2a16dcba5a31a45a12853a15254719c357baae6d (patch) | |
| tree | 92271c8ce54846e684cd874c8c2008651c3a9778 /main.go | |
| parent | d8bdce51c336f3693121202402ee38ff3f12c0e2 (diff) | |
| download | WRMS-2a16dcba5a31a45a12853a15254719c357baae6d.tar.gz WRMS-2a16dcba5a31a45a12853a15254719c357baae6d.zip | |
use an atomic pointer to track the current song
Also fix showing finished songs as current playing on new
clients.
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -232,7 +232,11 @@ func wsEndpoint(w http.ResponseWriter, r *http.Request) { initialCmds := [][]byte{} if wrms.Playing { - data, err := json.Marshal(newEvent("play", []Song{wrms.CurrentSong})) + var songs []Song + if currentSong := wrms.CurrentSong.Load(); currentSong != nil { + songs = []Song{*currentSong} + } + data, err := json.Marshal(newEvent("play", songs)) if err != nil { llog.Error("Encoding the play event failed with %s", err) return |
