Skip to content
Snippets Groups Projects
Commit 1392bea2 authored by Tóth Miklós Tibor's avatar Tóth Miklós Tibor :shrug:
Browse files

Fix notification daemon

parent 55a0ebc0
No related branches found
No related tags found
1 merge request!1Fix notification daemon
Pipeline #18208 failed
......@@ -15,10 +15,8 @@ var oldLaundry []model.LaundryRoom
func main() {
url := "https://mosogep.sch.bme.hu/api/v1/laundry-room/"
state := 0
for {
sendMsg(url)
state = testMsg(state)
time.Sleep(time.Second * 30)
}
......@@ -47,6 +45,7 @@ func sendMsg(url string) {
old := findOldMachine(machine.Id)
if old.Status != machine.Status {
machine.LastQueryTime = room.LastQueryTime
machine.FloorId = fmt.Sprintf("%d", room.Id)
marshal, err := json.Marshal(machine)
if err != nil {
log.Fatal(err)
......@@ -66,35 +65,3 @@ func sendMsg(url string) {
}
oldLaundry = laundryRooms
}
func testMsg(oldState int) int {
//fmt.Println("test sending...")
var state int
if oldState == 0 {
state = 1
} else {
state = 0
}
machine := model.Machine{
Id: 420,
KindOf: "DR",
Status: state,
Message: "",
LastQueryTime: time.Now(),
}
marshal, err := json.Marshal(machine)
if err != nil {
log.Fatal(err)
}
data := map[string]string{
"floor": "69",
"old_state": fmt.Sprintf("%d", oldState),
"machine": string(marshal),
}
err = firebase.Send("test", data)
if err != nil {
fmt.Println(err)
}
//fmt.Println("test sent...")
return state
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment