import * as http from 'http';
import { IVoiceEngine } from './types';
import { TwilioRealtimeEngine } from './twilio';

class EngineRegistry {
  private engines: IVoiceEngine[] = [];

  register(engine: IVoiceEngine): this {
    this.engines.push(engine);
    return this;
  }

  attach(server: http.Server): void {
    for (const engine of this.engines) {
      engine.attach(server);
    }
  }
}

const registry = new EngineRegistry();
registry.register(new TwilioRealtimeEngine());

export { registry as engineRegistry };
export type { EngineRegistry };
