Skip to content

Commit

Permalink
v2: add clean shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Jun 17, 2024
1 parent a670cc4 commit ec7f6db
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8
golang.org/x/net v0.26.0
google.golang.org/protobuf v1.34.2
maunium.net/go/mautrix v0.19.0-beta.1.0.20240617115738-3828c08f27fa
maunium.net/go/mautrix v0.19.0-beta.1.0.20240617130007-833995832be3
nhooyr.io/websocket v1.8.11
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
maunium.net/go/mauflag v1.0.0 h1:YiaRc0tEI3toYtJMRIfjP+jklH45uDHtT80nUamyD4M=
maunium.net/go/mauflag v1.0.0/go.mod h1:nLivPOpTpHnpzEh8jEdSL9UqO9+/KBJFmNRlwKfkPeA=
maunium.net/go/mautrix v0.19.0-beta.1.0.20240617115738-3828c08f27fa h1:9roSXY6+pcSY9jxnUprAi0gbbrUbFYcl5gAQSgNgXVs=
maunium.net/go/mautrix v0.19.0-beta.1.0.20240617115738-3828c08f27fa/go.mod h1:cxv1w6+syudmEpOewHYIQT9yO7TM5UOWmf6xEBVI4H4=
maunium.net/go/mautrix v0.19.0-beta.1.0.20240617130007-833995832be3 h1:FZ6uHxsDt9Z0/z8pgt6Ai+beV9+Te+RJBftgAgV7/r0=
maunium.net/go/mautrix v0.19.0-beta.1.0.20240617130007-833995832be3/go.mod h1:cxv1w6+syudmEpOewHYIQT9yO7TM5UOWmf6xEBVI4H4=
nhooyr.io/websocket v1.8.11 h1:f/qXNc2/3DpoSZkHt1DQu6rj4zGC8JmkkLkWss0MgN0=
nhooyr.io/websocket v1.8.11/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c=
8 changes: 8 additions & 0 deletions pkg/connector/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,11 +488,19 @@ func (s *SignalClient) bridgeStateLoop(statusChan <-chan signalmeow.SignalConnec
}
}
}

func (s *SignalClient) Connect(ctx context.Context) error {
s.tryConnect(ctx, 0)
return nil
}

func (s *SignalClient) Disconnect() {
err := s.Client.StopReceiveLoops()
if err != nil {
s.UserLogin.Log.Err(err).Msg("Failed to stop receive loops")
}
}

func (s *SignalClient) tryConnect(ctx context.Context, retryCount int) {
ch, err := s.Client.StartReceiveLoops(ctx)
if err != nil {
Expand Down

0 comments on commit ec7f6db

Please sign in to comment.