From 5b94b528ae1a6a6c05f32ece85dcf1a6d61e30d7 Mon Sep 17 00:00:00 2001 From: Pavlo Buidenkov Date: Sat, 28 May 2022 22:46:06 +0200 Subject: [PATCH] unmark room id taken handler --- app/features/PeerConnection/handleSelfDestroy.ts | 4 +++- app/features/PeerConnection/index.ts | 2 +- app/main/ipcMainHandlers.ts | 8 ++++++++ app/utils/mainProcessHelpers/DeskreenGlobal.d.ts | 1 + .../mainProcessHelpers/DeskreenGlobalService.enum.ts | 4 ++++ 5 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 app/utils/mainProcessHelpers/DeskreenGlobalService.enum.ts diff --git a/app/features/PeerConnection/handleSelfDestroy.ts b/app/features/PeerConnection/handleSelfDestroy.ts index 1803e55..1c73c1a 100644 --- a/app/features/PeerConnection/handleSelfDestroy.ts +++ b/app/features/PeerConnection/handleSelfDestroy.ts @@ -1,3 +1,4 @@ +import { ipcRenderer } from 'electron'; import SharingSessionStatusEnum from '../SharingSessionService/SharingSessionStatusEnum'; import NullSimplePeer from './NullSimplePeer'; import NullUser from './NullUser'; @@ -27,5 +28,6 @@ export default function handleSelfDestroy(peerConnection: PeerConnection) { peerConnection.onDeviceConnectedCallback = () => {}; peerConnection.isCallStarted = false; peerConnection.socket.disconnect(); - peerConnection.roomIDService.unmarkRoomIDAsTaken(peerConnection.roomID); + + ipcRenderer.invoke('unmark-room-id-as-taken', peerConnection.roomID); } diff --git a/app/features/PeerConnection/index.ts b/app/features/PeerConnection/index.ts index 7db8373..fd0e636 100644 --- a/app/features/PeerConnection/index.ts +++ b/app/features/PeerConnection/index.ts @@ -56,6 +56,7 @@ export default class PeerConnection { this.roomIDService = roomIDService; this.connectedDevicesService = connectedDevicesService; this.sharingSessionService = sharingSessionsService; + this.desktopCapturerSourcesService = desktopCapturerSourcesService; this.sharingSessionID = sharingSessionID; this.isSocketRoomLocked = false; this.roomID = encodeURI(roomID); @@ -69,7 +70,6 @@ export default class PeerConnection { this.localStream = null; this.displayID = ''; this.sourceDisplaySize = undefined; - this.desktopCapturerSourcesService = desktopCapturerSourcesService; this.onDeviceConnectedCallback = () => {}; handleSocket(this); diff --git a/app/main/ipcMainHandlers.ts b/app/main/ipcMainHandlers.ts index 7c2c6a6..19297f2 100644 --- a/app/main/ipcMainHandlers.ts +++ b/app/main/ipcMainHandlers.ts @@ -6,6 +6,7 @@ import SharingSession from '../features/SharingSessionService/SharingSession'; import RoomIDService from '../server/RoomIDService'; import getDeskreenGlobal from '../utils/mainProcessHelpers/getDeskreenGlobal'; import signalingServer from '../server'; +import { DeskreenGlobalService } from '../utils/mainProcessHelpers/DeskreenGlobalService.enum'; const v4IPGetter = require('internal-ip').v4; @@ -84,4 +85,11 @@ export default function initIpcMainHandlers( const deskreenGlobal = getDeskreenGlobal(); return deskreenGlobal.appPath; }); + + ipcMain.handle('unmark-room-id-as-taken', (_, roomID) => { + const deskreenGlobal = getDeskreenGlobal(); + deskreenGlobal[DeskreenGlobalService.RoomIDService].unmarkRoomIDAsTaken( + roomID + ); + }); } diff --git a/app/utils/mainProcessHelpers/DeskreenGlobal.d.ts b/app/utils/mainProcessHelpers/DeskreenGlobal.d.ts index e3dbae8..c7994a7 100644 --- a/app/utils/mainProcessHelpers/DeskreenGlobal.d.ts +++ b/app/utils/mainProcessHelpers/DeskreenGlobal.d.ts @@ -3,6 +3,7 @@ import SharingSessionService from '../../features/SharingSessionService'; import RendererWebrtcHelpersService from '../../features/PeerConnectionHelperRendererService'; import RoomIDService from '../../server/RoomIDService'; import DesktopCapturerSources from '../../features/DesktopCapturerSourcesService'; +import DeskreenGlobalService from './DeskreenGlobalService.enum'; interface DeskreenGlobal { appPath: string; diff --git a/app/utils/mainProcessHelpers/DeskreenGlobalService.enum.ts b/app/utils/mainProcessHelpers/DeskreenGlobalService.enum.ts new file mode 100644 index 0000000..ac5d959 --- /dev/null +++ b/app/utils/mainProcessHelpers/DeskreenGlobalService.enum.ts @@ -0,0 +1,4 @@ +// eslint-disable-next-line import/prefer-default-export +export enum DeskreenGlobalService { + RoomIDService = 'roomIDService', +}