// TODO: what is managed here except current active application?
export class DataBridgeConnectionManager {
  private static activeConn = {}

  static set(name: string, body: string) {
    if (body === 'start') {
      if (DataBridgeConnectionManager.getActive() === '' || DataBridgeConnectionManager.getActive() === name) {
        DataBridgeConnectionManager.activeConn[name] = true
      }
    } else if (body === 'exit') {
      DataBridgeConnectionManager.activeConn[name] = false
    }
  }

  static getActive(): string {
    return (
      Object.keys(DataBridgeConnectionManager.activeConn)
        .find(appName => DataBridgeConnectionManager.activeConn[appName] == true)
        ?.toString() || ''
    )
  }
}
