Skip to content

Commit

Permalink
bridgev2: add optional stop method for network connectors
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Oct 14, 2024
1 parent efc532b commit 965008e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bridgev2/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ func (br *Bridge) Stop() {
}
wg.Wait()
br.cacheLock.Unlock()
if stopNet, ok := br.Network.(StoppableNetwork); ok {
stopNet.Stop()
}
err := br.DB.Close()
if err != nil {
br.Log.Warn().Err(err).Msg("Failed to close database")
Expand Down
5 changes: 5 additions & 0 deletions bridgev2/networkinterface.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ type NetworkConnector interface {
CreateLogin(ctx context.Context, user *User, flowID string) (LoginProcess, error)
}

type StoppableNetwork interface {
// Stop is called when the bridge is stopping, after all network clients have been disconnected.
Stop()
}

// DirectMediableNetwork is an optional interface that network connectors can implement to support direct media access.
//
// If the Matrix connector has direct media enabled, SetUseDirectMedia will be called
Expand Down

0 comments on commit 965008e

Please sign in to comment.