init session after auth
This commit is contained in:
parent
798b848c9b
commit
a6351af83c
8 changed files with 46 additions and 49 deletions
|
|
@ -21,12 +21,3 @@ const handlers = [loginHandler, logoutHandler];
|
|||
|
||||
export default handlers;
|
||||
|
||||
// export default function useAccountListeners(): void {
|
||||
//
|
||||
// ipcMain.removeHandler(LOGIN_HANDLER);
|
||||
// ipcMain.handle(LOGIN_HANDLER, onLogin);
|
||||
//
|
||||
// ipcMain.removeHandler(LOGOUT_HANDLER);
|
||||
// ipcMain.handle(LOGOUT_HANDLER, onLogout);
|
||||
//
|
||||
// }
|
||||
|
|
|
|||
|
|
@ -3,6 +3,10 @@
|
|||
|
||||
import { ipcMain, IpcMainInvokeEvent, IpcMainEvent } from "electron";
|
||||
import { collect, flush } from "@/composbales/audio";
|
||||
import { IpcHandler } from "@/composables/useIpcMain";
|
||||
|
||||
const AUDIO_CHUNK_CHANNEL = 'audio-chunk';
|
||||
const GET_AUDIO_CHANNEL = 'get-audio';
|
||||
|
||||
// handle the new audio data
|
||||
const onAudioChunk = (
|
||||
|
|
@ -13,14 +17,10 @@ const onAudioChunk = (
|
|||
collect(payload);
|
||||
}
|
||||
|
||||
// Returns recorded audio to frontend and sets record to false.
|
||||
const onGetAudio = async (
|
||||
_event: IpcMainInvokeEvent,
|
||||
_payload: null
|
||||
): Promise<Error | ArrayBuffer[]> => {
|
||||
console.log('[IPC]: stop-recording');
|
||||
return await flush()
|
||||
};
|
||||
const getAudioHandler = new IpcHandler({
|
||||
channel: GET_AUDIO_CHANNEL,
|
||||
handlerCallback: flush
|
||||
});
|
||||
|
||||
|
||||
export default function useAudioListeners(): void {
|
||||
|
|
@ -28,7 +28,4 @@ export default function useAudioListeners(): void {
|
|||
ipcMain.removeAllListeners("audio-chunk");
|
||||
ipcMain.on("audio-chunk", onAudioChunk);
|
||||
|
||||
ipcMain.removeHandler("get-audio");
|
||||
ipcMain.handle("get-audio", onGetAudio);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"use strict";
|
||||
|
||||
import {IpcHandler} from "@/composables/useIpcMain";
|
||||
import handlers from "./account";
|
||||
import accountHandlers from "./account";
|
||||
import useSessionListeners from "./session";
|
||||
// import useAudioListeners from "./audio";
|
||||
|
||||
|
|
@ -12,8 +12,8 @@ interface IPCHandlers {
|
|||
|
||||
const ipcHandlers: IPCHandlers = {};
|
||||
|
||||
const _initHandlers = () => {
|
||||
handlers.forEach((h) => {
|
||||
const _initHandlers = (handlers: Array<IpcHandler<any, any>>) => {
|
||||
handlers.forEach((h: IpcHandler<any, any>) => {
|
||||
if (!(h.channel in ipcHandlers)) {
|
||||
ipcHandlers[h.channel] = h;
|
||||
h.handle();
|
||||
|
|
@ -23,7 +23,7 @@ const _initHandlers = () => {
|
|||
|
||||
export default function useIpc(): void {
|
||||
|
||||
_initHandlers();
|
||||
_initHandlers(accountHandlers);
|
||||
|
||||
// useAccountListeners();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
import { ipcMain, IpcMainEvent, IpcMainInvokeEvent } from "electron";
|
||||
import { ipcMain, IpcMainEvent } from "electron";
|
||||
import { sendMessage } from '@/session';
|
||||
|
||||
// Handle messages from window/client.
|
||||
|
|
@ -9,11 +9,6 @@ function onSendMessage(_event: IpcMainEvent, payload: Message): void {
|
|||
sendMessage(payload);
|
||||
}
|
||||
|
||||
// Login attempt, returns success or not.
|
||||
function onLogin(_event: IpcMainEvent, payload: LoginPayload): void {
|
||||
console.log('hello')
|
||||
}
|
||||
|
||||
export default function useSessionListeners(): void {
|
||||
ipcMain.removeAllListeners("client-message");
|
||||
ipcMain.on("client-message", onSendMessage);
|
||||
|
|
|
|||
Loading…
Reference in a new issue