add authenticate on socket connect

This commit is contained in:
Enrique Hernandez 2021-02-09 17:07:45 -06:00
commit e0da50eb27
7 changed files with 112 additions and 70 deletions

View file

@ -14,12 +14,6 @@ interface ipcRendererPayload {
*/
export function main(): void {
// Instantiate socket session with crimata-platorm.
initSession();
// mount auth-user listener
ipcMain.on('auth-user', authUser);
// create main window.
const win = createWindow({ width: 350, height: 525, resizable: false });
@ -34,18 +28,17 @@ export function main(): void {
}
const windowMount = (): void => {
// Instantiate socket session with crimata-platorm.
initSession();
windowEmitter.emit('window-active', true);
// ipc event handlers
ipcMain.on('send-message', handleMessage);
ipcMain.on('auth-login', authLogin);
}
const windowDismount = (): void => {
windowEmitter.emit('window-active', false);
// TODO: Gracefully close socket connection
ipcMain.removeAllListeners('send-message');
ipcMain.removeAllListeners('auth-login');
ipcMain.removeAllListeners('auth-user');
}
// Handle window mount and dismount.