import { ChatMessage } from './../../model/common-model';
import { autoinject } from "aurelia-framework";
import { AbstractHubClient } from './abstract-hub-client';

@autoinject
export class CommunicationHubClient extends AbstractHubClient {

  protected get endpoint(): string {
    return '/notificationHub';
  }

  public onUpdateNotificationCounter(listener: (notificationId: number) => void) {
    return this.subscribe('updateNotificationCounter', listener);
  }

  public onNewMessage(listener: (topic: string, data: ChatMessage) => void) {
    return this.subscribe('onNewMessage', listener);
  }

  public subscribeToTopic(topic: string) {
    this.send('subscribe', topic);
  }
  public unsubscribeToTopic(topic: string) {
    this.send('unsubscribe', topic);
  }
}