diff --git a/commonspace/peerstatus/status.go b/commonspace/peerstatus/status.go new file mode 100644 index 00000000..f6fd0ba5 --- /dev/null +++ b/commonspace/peerstatus/status.go @@ -0,0 +1,20 @@ +package peerstatus + +import ( + "github.com/anyproto/any-sync/app" +) + +type Status int32 + +const ( + Unknown Status = 0 + Connected Status = 1 + NotPossible Status = 2 + NotConnected Status = 3 +) + +type StatusUpdateSender interface { + app.ComponentRunnable + SendPeerUpdate() + SendNewStatus(status Status) +} diff --git a/commonspace/spaceservice.go b/commonspace/spaceservice.go index 8cd15b6c..83fbf402 100644 --- a/commonspace/spaceservice.go +++ b/commonspace/spaceservice.go @@ -32,6 +32,7 @@ import ( "github.com/anyproto/any-sync/commonspace/objectsync" "github.com/anyproto/any-sync/commonspace/objecttreebuilder" "github.com/anyproto/any-sync/commonspace/peermanager" + "github.com/anyproto/any-sync/commonspace/peerstatus" "github.com/anyproto/any-sync/commonspace/requestmanager" "github.com/anyproto/any-sync/commonspace/settings" "github.com/anyproto/any-sync/commonspace/spacestate" @@ -67,6 +68,7 @@ type SpaceService interface { type Deps struct { TreeSyncer treesyncer.TreeSyncer + PeerStatus peerstatus.StatusUpdateSender } type spaceService struct { @@ -179,6 +181,7 @@ func (s *spaceService) NewSpace(ctx context.Context, id string, deps Deps) (Spac statusService := s.statusServiceProvider.NewStatusService() spaceApp := s.app.ChildApp() spaceApp.Register(state). + Register(deps.PeerStatus). Register(peerManager). Register(newCommonStorage(st)). Register(statusService).