Log Satel disconnections
This commit is contained in:
parent
0cb91aed62
commit
765a41f8a1
14
filters.go
14
filters.go
|
@ -79,3 +79,17 @@ func FilterByLastSeen(ev <-chan satel.Event, dataStore *DataStore, logger *log.L
|
|||
|
||||
return returnChan
|
||||
}
|
||||
|
||||
func CallWhenClosed(ev <-chan satel.Event, cbk func()) <-chan satel.Event {
|
||||
returnChan := make(chan satel.Event)
|
||||
|
||||
go func() {
|
||||
for e := range ev {
|
||||
returnChan <- e
|
||||
}
|
||||
cbk()
|
||||
close(returnChan)
|
||||
}()
|
||||
|
||||
return returnChan
|
||||
}
|
||||
|
|
4
main.go
4
main.go
|
@ -147,7 +147,9 @@ func main() {
|
|||
go CloseSatelOnCtrlC(s)
|
||||
|
||||
for e := range FilterByIndex(FilterByType(
|
||||
FilterByLastSeen(s.Events, &dataStore, log.New(os.Stderr, "FilterByLastSeen", log.Lmicroseconds)),
|
||||
FilterByLastSeen(
|
||||
CallWhenClosed(s.Events, func() { logger.Print("Satel disconnected.") }),
|
||||
&dataStore, log.New(os.Stderr, "FilterByLastSeen", log.Lmicroseconds)),
|
||||
allowedTypes),
|
||||
allowedIndexes) {
|
||||
logger.Print("Received change from SATEL: ", e)
|
||||
|
|
Loading…
Reference in New Issue