1
0
mirror of https://github.com/pavlobu/deskreen.git synced 2025-05-16 15:30:20 -07:00
deskreen/app/peerConnectionHelperRendererWindowIndex.tsx
Pavlo Buidenkov b925803d9f better client UI code
huge work done on sharing desktop session
2020-11-22 17:07:01 +02:00

51 lines
1.5 KiB
TypeScript

import { ipcRenderer, remote } from 'electron';
import ConnectedDevicesService from './features/ConnectedDevicesService';
import PeerConnection from './features/PeerConnection';
import SharingSessionService from './features/SharingSessionsService';
import RoomIDService from './server/RoomIDService';
const roomIDService = remote.getGlobal('roomIDService') as RoomIDService;
const connectedDevicesService = remote.getGlobal(
'connectedDevicesService'
) as ConnectedDevicesService;
const sharingSessionsService = remote.getGlobal(
'sharingSessionService'
) as SharingSessionService;
let peerConnection: PeerConnection;
ipcRenderer.on('create-peer-connection-with-data', (_, data) => {
peerConnection = new PeerConnection(
data.roomID,
data.sharingSessionID,
data.user,
roomIDService,
connectedDevicesService,
sharingSessionsService
);
peerConnection.setOnDeviceConnectedCallback((deviceData) => {
ipcRenderer.send('peer-connected', deviceData);
});
});
ipcRenderer.on('set-desktop-capturer-source-id', (_, id) => {
peerConnection.setDesktopCapturerSourceID(id);
});
ipcRenderer.on('call-peer', () => {
peerConnection.callPeer();
});
ipcRenderer.on('disconnect-by-host-machine-user', () => {
peerConnection.disconnectByHostMachineUser();
});
ipcRenderer.on('deny-connection-for-partner', () => {
peerConnection.denyConnectionForPartner();
});
ipcRenderer.on('send-user-allowed-to-connect', () => {
peerConnection.sendUserAllowedToConnect();
});