import { inject, injectable } from 'inversify'; import { IpcServer } from '../ipc/ipc-server'; import { INhentaiApi } from './i-nhentai-api'; @injectable() export class NhentaiIpcServer extends IpcServer { private nhentaiApi: INhentaiApi; public constructor(@inject(Symbol.for('nhentai-api')) nhentaiApi: INhentaiApi) { super(); this.nhentaiApi = nhentaiApi; this.answer(IpcChannels.LOGIN, (credentials: ICredentials) => this.nhentaiApi.login(credentials.name, credentials.password) ); this.answer(IpcChannels.LOGGED_IN, () => this.nhentaiApi.isLoggedIn()); } }