Upgrade SignalR (#1991)

This commit is contained in:
andig 2021-12-05 21:22:17 +01:00 • committed by GitHub
parent d5ad717eca
commit 455f5b768c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 7 deletions

View file

@ -115,7 +115,7 @@ func NewEasee(user, password, charger string, circuit int, cache time.Duration)
}
client, err := signalr.NewClient(context.Background(),
signalr.WithAutoReconnect(c.connect(ts)),
signalr.WithConnector(c.connect(ts)),
signalr.WithReceiver(c),
signalr.Logger(easee.SignalrLogger(c.log.TRACE), false),
)
@ -169,12 +169,12 @@ func (c *Easee) connect(ts oauth2.TokenSource) func() (signalr.Connection, error
// subscribe listen to state changes and sends subscription requests when connection is established
func (c *Easee) subscribe(client signalr.Client) {
stateC := make(chan struct{}, 1)
stateC := make(chan signalr.ClientState, 1)
_ = client.ObserveStateChanged(stateC)
go func() {
for range stateC {
if client.State() == signalr.ClientConnected {
for state := range stateC {
if state == signalr.ClientConnected {
if err := <-client.Send("SubscribeWithCurrentState", c.charger, true); err != nil {
c.log.ERROR.Printf("SubscribeWithCurrentState: %v", err)
}

2
go.mod
View file

@ -68,7 +68,7 @@ require (
github.com/olekukonko/tablewriter v0.0.5
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/onsi/gomega v1.17.0 // indirect
github.com/philippseith/signalr v0.5.2
github.com/philippseith/signalr v0.5.3-0.20211205201131-d57b5a34379a
github.com/prometheus/client_golang v1.11.0
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect

4
go.sum
View file

@ -625,8 +625,8 @@ github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCko
github.com/pelletier/go-toml v1.9.4 h1:tjENF6MfZAg8e4ZmZTeWaWiT2vXtsoO6+iuOjFhECwM=
github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/peterbourgon/ff v1.2.0/go.mod h1:ljiF7yxtUvZaxUDyUqQa0+uiEOgwVboj+Q2S2+0nq40=
github.com/philippseith/signalr v0.5.2 h1:lI5Mn0n0vw/ItwDzDa5rXhvMVBrIJYcpw6UvRb/P8hM=
github.com/philippseith/signalr v0.5.2/go.mod h1:lvHqx1JLduRcRHqWiDX6u/LHtSsfb08g+e+QP/B2gTA=
github.com/philippseith/signalr v0.5.3-0.20211205201131-d57b5a34379a h1:wLffcAusLojxT9PRjguscJLi2+xIagvQi9ScM9UwVHw=
github.com/philippseith/signalr v0.5.3-0.20211205201131-d57b5a34379a/go.mod h1:lvHqx1JLduRcRHqWiDX6u/LHtSsfb08g+e+QP/B2gTA=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=