correction gestion deconnexion
This commit is contained in:
parent
9bc06cb150
commit
a709ba65aa
13
cmd/main.go
13
cmd/main.go
@ -2,12 +2,25 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"path"
|
||||
"runtime"
|
||||
|
||||
"git.lehouerou.net/laurent/arlo-go"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.SetLevel(log.TraceLevel)
|
||||
log.SetFormatter(&log.TextFormatter{
|
||||
ForceColors: true,
|
||||
FullTimestamp: true,
|
||||
TimestampFormat: "02-01-2006 15:04:05",
|
||||
CallerPrettyfier: func(f *runtime.Frame) (string, string) {
|
||||
filename := path.Base(f.File)
|
||||
return fmt.Sprintf("%s()", f.Function), fmt.Sprintf("%s:%d", filename, f.Line)
|
||||
},
|
||||
})
|
||||
ctx := context.Background()
|
||||
a := arlo.NewArlo()
|
||||
err := a.Login(ctx, "hass@lehouerou.net", "TiPXMVLUeZfUg6RrmwzK")
|
||||
|
@ -87,11 +87,13 @@ func (e *eventStream) listen(ctx context.Context) error {
|
||||
return
|
||||
case event, ok := <-e.Events:
|
||||
if !ok {
|
||||
e.disconnect()
|
||||
return
|
||||
}
|
||||
|
||||
if event == nil || event.Data == nil {
|
||||
log.Warn("EventStream > nil event or nil data in event")
|
||||
e.disconnect()
|
||||
continue
|
||||
}
|
||||
|
||||
@ -99,6 +101,8 @@ func (e *eventStream) listen(ctx context.Context) error {
|
||||
e.setLastId(string(event.ID))
|
||||
}
|
||||
|
||||
log.Tracef("Data > %s", event.Data)
|
||||
|
||||
var notifyResponse EventStreamResponse
|
||||
err := json.NewDecoder(bytes.NewBuffer(event.Data)).Decode(¬ifyResponse)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user