import assertUnreachable from 'lang/assertUnreachable';

export enum PhenixWebSocketMessage {
  Authenticate = 0,
  Bye = 1
}

export type PhenixWebSocketMessageType = 'pcast.Authenticate' | 'pcast.Bye';

export class PhenixWebSocketMessageMapping {
  public static convertPhenixWebSocketMessageToPhenixWebSocketMessageType(message: PhenixWebSocketMessage): PhenixWebSocketMessageType {
    switch (message) {
      case PhenixWebSocketMessage.Authenticate:
        return 'pcast.Authenticate';
      case PhenixWebSocketMessage.Bye:
        return 'pcast.Bye';

      default:
        assertUnreachable(message);
    }
  }

  public static convertPhenixWebSocketMessageTypeToPhenixWebSocketMessage(messageType: PhenixWebSocketMessageType): PhenixWebSocketMessage {
    switch (messageType) {
      case 'pcast.Authenticate':
        return PhenixWebSocketMessage.Authenticate;
      case 'pcast.Bye':
        return PhenixWebSocketMessage.Bye;
      default:
        assertUnreachable(messageType);
    }
  }
}
