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 (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"path"
|
||||||
|
"runtime"
|
||||||
|
|
||||||
"git.lehouerou.net/laurent/arlo-go"
|
"git.lehouerou.net/laurent/arlo-go"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
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()
|
ctx := context.Background()
|
||||||
a := arlo.NewArlo()
|
a := arlo.NewArlo()
|
||||||
err := a.Login(ctx, "hass@lehouerou.net", "TiPXMVLUeZfUg6RrmwzK")
|
err := a.Login(ctx, "hass@lehouerou.net", "TiPXMVLUeZfUg6RrmwzK")
|
||||||
|
@ -87,11 +87,13 @@ func (e *eventStream) listen(ctx context.Context) error {
|
|||||||
return
|
return
|
||||||
case event, ok := <-e.Events:
|
case event, ok := <-e.Events:
|
||||||
if !ok {
|
if !ok {
|
||||||
|
e.disconnect()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if event == nil || event.Data == nil {
|
if event == nil || event.Data == nil {
|
||||||
log.Warn("EventStream > nil event or nil data in event")
|
log.Warn("EventStream > nil event or nil data in event")
|
||||||
|
e.disconnect()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,6 +101,8 @@ func (e *eventStream) listen(ctx context.Context) error {
|
|||||||
e.setLastId(string(event.ID))
|
e.setLastId(string(event.ID))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Tracef("Data > %s", event.Data)
|
||||||
|
|
||||||
var notifyResponse EventStreamResponse
|
var notifyResponse EventStreamResponse
|
||||||
err := json.NewDecoder(bytes.NewBuffer(event.Data)).Decode(¬ifyResponse)
|
err := json.NewDecoder(bytes.NewBuffer(event.Data)).Decode(¬ifyResponse)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user