Aa
This commit is contained in:
33
main.js
33
main.js
@@ -16,6 +16,7 @@ let socket = null;
|
||||
let peerConnection = null;
|
||||
let displayId = null;
|
||||
let offer = null;
|
||||
let sources = null;
|
||||
|
||||
// 자동 시작 설정
|
||||
app.setLoginItemSettings({
|
||||
@@ -54,10 +55,9 @@ function createTray() {
|
||||
// 🖥️ 사용 가능한 디스플레이 목록 전송
|
||||
async function sendAvailableDisplays() {
|
||||
try {
|
||||
const sources = await desktopCapturer.getSources({ types: ['screen'] });
|
||||
sources = await desktopCapturer.getSources({ types: ['screen'] });
|
||||
const source = sources[0];
|
||||
displayId = source.id
|
||||
console.log('sources',sources)
|
||||
const displays = sources.map(source => ({
|
||||
id: source.id,
|
||||
name: source.name,
|
||||
@@ -104,17 +104,22 @@ function connectToSignaling() {
|
||||
reconnectionDelay: 2000
|
||||
});
|
||||
|
||||
socket.on('connect', () => {
|
||||
socket.on('connect', (data) => {
|
||||
console.log('시그널링 서버 연결됨. 직원 등록 중...');
|
||||
socket.emit('register', EMPLOYEE_ID);
|
||||
sendAvailableDisplays(); // 연결 시 디스플레이 목록 전송
|
||||
|
||||
// rendererWindow.webContents.send('connection', data);
|
||||
});
|
||||
|
||||
socket.on('controlRequest', async (data) => {
|
||||
|
||||
/*연결 요청 -> webrtc 시작 -> offer 전송*/
|
||||
socket.on('responseControl', async (data) => {
|
||||
console.log(data)
|
||||
const result = await dialog.showMessageBox({
|
||||
type: 'question',
|
||||
title: '원격 연결 요청',
|
||||
message: `관리자로부터 원격 제어 요청이 왔습니다.\n허용하시겠습니까? ${displayId}`,
|
||||
message: `관리자로부터 원격 제어 요청이 왔습니다.\n허용하시겠습니까? ${data.displayId}`,
|
||||
buttons: ['허용', '거부'],
|
||||
defaultId: 1,
|
||||
cancelId: 1
|
||||
@@ -123,16 +128,20 @@ function connectToSignaling() {
|
||||
if (result.response === 0) {
|
||||
// ✅ 렌더러 프로세스에 WebRTC 시작 명령 전달
|
||||
rendererWindow.webContents.send('start-webrtc', {
|
||||
offer: data.offer,
|
||||
displayId,
|
||||
signalingServer: SIGNALING_SERVER,
|
||||
targetId: data.from
|
||||
displayId: data.displayId,
|
||||
targetId: data.targetId,
|
||||
sources
|
||||
});
|
||||
} else {
|
||||
socket.emit('webrtcSignal', { targetId: data.from, data: { type: 'reject' } });
|
||||
socket.emit('webrtcSignal', { targetId: data.targetId, data: { type: 'reject' } });
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('answer', async (data) => {
|
||||
rendererWindow.webContents.send('answer', data);
|
||||
console.log('answer', data);
|
||||
})
|
||||
|
||||
// WebRTC 신호 수신 (ICE candidate 등)
|
||||
socket.on('webrtcSignal', async (data) => {
|
||||
rendererWindow.webContents.send('webrtcSignal', data);
|
||||
@@ -186,3 +195,7 @@ ipcMain.on('input-event-from-renderer', (event, data) => {
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
ipcMain.on('offer', (event, data) => {
|
||||
socket.emit('offer', data);
|
||||
})
|
||||
Reference in New Issue
Block a user