-
Notifications
You must be signed in to change notification settings - Fork 2
/
rigStatus.go
36 lines (30 loc) · 921 Bytes
/
rigStatus.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"errors"
"github.com/PiotrTopa/js8web/model"
)
var rigStatusCache model.RigStatusWsEvent = model.RigStatusWsEvent{}
func rigStatusNotifier(event *model.Js8callEvent, websocketEvents chan<- model.WebsocketEvent, databaseObjects chan<- model.DbObj) error {
newRigStatus, err := model.CreateRigStatusWsEvent(event)
if err != nil {
logger.Sugar().Errorw(
"Can not undertand RIG.STATUS event",
"event", event,
"error", err,
)
return nil
}
if *newRigStatus != rigStatusCache {
rigStatusCache = *newRigStatus
websocketEvents <- &rigStatusCache
}
return nil
}
func rigPttNotifier(event *model.Js8callEvent, websocketEvents chan<- model.WebsocketEvent, databaseObjects chan<- model.DbObj) error {
wsEvent, err := model.CreateRigPttWsEvent(event)
if err != nil {
return errors.New("can not convert TxFrame event to db object")
}
websocketEvents <- wsEvent
return nil
}