-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removes Elm, and uses plain JSON as protocol.
- Loading branch information
Showing
29 changed files
with
991 additions
and
2,196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1 @@ | ||
siren/siren | ||
siren/static.go | ||
siren/dist | ||
elm/elm-stuff/ | ||
docroot/s/main.js | ||
siren |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,24 @@ | ||
.PHONY: build build-pi preparerelease release fakerelease | ||
.PHONY: all test build build-pi run preparerelease release fakerelease | ||
|
||
all: test build | ||
|
||
test: | ||
go test | ||
|
||
build: | ||
$(MAKE) -C elm | ||
$(MAKE) -C siren | ||
go build | ||
|
||
build-pi: static | ||
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build | ||
|
||
build-pi: | ||
$(MAKE) -C elm | ||
$(MAKE) -C siren build-pi | ||
run: build | ||
./siren -docroot ./docroot | ||
|
||
preparerelease: | ||
$(MAKE) -C elm | ||
$(MAKE) -C siren static | ||
preparerelease: test build | ||
go get -v github.com/goreleaser/goreleaser | ||
|
||
release: preparerelease | ||
cd siren && goreleaser --rm-dist | ||
goreleaser --rm-dist | ||
|
||
fakerelease: preparerelease | ||
cd siren && goreleaser --rm-dist --snapshot | ||
goreleaser --rm-dist --snapshot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
function runWS(wsURL, ui) { | ||
console.log("connecting to ", wsURL); | ||
const ws = new WebSocket(wsURL); | ||
ws.addEventListener('open', function (event) { | ||
console.log("got ws connection"); | ||
ui.setConnected(true, undefined); | ||
ui.sendCmd = function(name, payload) { | ||
if (payload === undefined) { | ||
payload = {}; | ||
} | ||
ws.send(JSON.stringify({"name": name, "value": payload})); | ||
} | ||
}); | ||
ws.addEventListener('close', function (event) { | ||
console.log("lost ws connection"); | ||
ui.setConnected(false, function() { runWS(wsURL, ui) }); | ||
}); | ||
ws.addEventListener('message', function (event) { | ||
const msg = JSON.parse(event.data); | ||
handleMsg(msg.name, msg.value, ui); | ||
}); | ||
}; | ||
|
||
function handleMsg(msgName, payload, ui) { | ||
switch(msgName) { | ||
case "siren/config": | ||
ui.mpdhost = payload.mpdhost; | ||
ui.artistmode = payload.artistmode; | ||
break; | ||
case "siren/connection": | ||
ui.setMPDConnected(payload); | ||
break; | ||
case "siren/playlist": | ||
ui.setPlaylist(payload); | ||
break; | ||
case "siren/status": | ||
ui.setPlaybackStatus(payload.songid, payload.state, payload.duration, payload.elapsed); | ||
break; | ||
case "siren/list": | ||
ui.setList(payload.id, payload.list); | ||
break; | ||
case "siren/inodes": | ||
ui.setInodes(payload.id, payload.inodes); | ||
break; | ||
case "siren/track": | ||
ui.setTrack(payload.id, payload.track); | ||
break; | ||
default: | ||
console.log("unhandled message type", msgName, payload); | ||
} | ||
} |
Oops, something went wrong.