import type { HubConnection } from '@microsoft/signalr'
import { HubConnectionBuilder } from '@microsoft/signalr'
// https://www.abrahamberg.com/blog/aspnet-signalr-and-react/
export class Hub {
  public hub: HubConnection
  constructor(name: string, baseUrl: string) {
    this.hub = new HubConnectionBuilder()
      .withUrl(baseUrl + '/' + name)
      .withAutomaticReconnect()
      .build()
    try {
      this.hub.start()
    } catch (err) {
      // eslint-disable-next-line no-console
      console.log(err)
    }
  }
}
