2020-11-10 00:30:27 +00:00
|
|
|
import { ipcMain } from 'electron';
|
2021-07-22 23:04:56 +00:00
|
|
|
|
2020-11-10 00:30:27 +00:00
|
|
|
import { GrpcRequestEventEnum } from '../common/grpc-events';
|
2021-07-22 23:04:56 +00:00
|
|
|
import * as grpc from '../network/grpc';
|
2021-05-12 06:35:00 +00:00
|
|
|
import { GrpcIpcRequestParams } from '../network/grpc/prepare';
|
2021-07-22 23:04:56 +00:00
|
|
|
import { ResponseCallbacks } from '../network/grpc/response-callbacks';
|
2020-11-10 00:30:27 +00:00
|
|
|
|
|
|
|
export function init() {
|
2020-12-17 11:38:21 +00:00
|
|
|
ipcMain.on(GrpcRequestEventEnum.start, (e, params: GrpcIpcRequestParams) =>
|
|
|
|
grpc.start(params, new ResponseCallbacks(e)),
|
2020-11-10 00:30:27 +00:00
|
|
|
);
|
2020-12-17 11:38:21 +00:00
|
|
|
ipcMain.on(GrpcRequestEventEnum.sendMessage, (e, params: GrpcIpcRequestParams) =>
|
2021-05-12 06:35:00 +00:00
|
|
|
// @ts-expect-error -- TSCONVERSION
|
2020-12-17 11:38:21 +00:00
|
|
|
grpc.sendMessage(params, new ResponseCallbacks(e)),
|
2020-11-10 00:30:27 +00:00
|
|
|
);
|
|
|
|
ipcMain.on(GrpcRequestEventEnum.commit, (_, requestId) => grpc.commit(requestId));
|
|
|
|
ipcMain.on(GrpcRequestEventEnum.cancel, (_, requestId) => grpc.cancel(requestId));
|
2020-11-16 22:01:50 +00:00
|
|
|
ipcMain.on(GrpcRequestEventEnum.cancelMultiple, (_, requestIdS) =>
|
|
|
|
grpc.cancelMultiple(requestIdS),
|
|
|
|
);
|
2020-11-10 00:30:27 +00:00
|
|
|
}
|