This commit is contained in:
bangae1
2025-10-22 14:56:52 +09:00
parent 1847f25fa3
commit e5aa5d1d5c
2 changed files with 57 additions and 44 deletions

View File

@@ -2,6 +2,7 @@
let peerConnection = null;
let currentStream = null;
let dataChannel = null;
let connection = false;
// 메인 프로세스로부터 명령 수신 (IPC)
console.log('electronAPI:', window.electronAPI);
@@ -53,6 +54,16 @@ window.electronAPI.receive('start-webrtc', async (data) => {
window.electronAPI.send('icecandidate', {type: 'icecandidate', targetId: data.targetId, server:'agent', 'candidate': event.candidate});
}, 2000)
}
peerConnection.ondatachannel = (event) => {
console.log('datachannel', event);
dataChannel = event.channel;
dataChannel.onmessage = (event) => {
window.electronAPI.send('inputEvent', JSON.parse(event.data))
}
}
});
window.electronAPI.receive('displays', async (data) => {
@@ -66,5 +77,10 @@ window.electronAPI.receive('icecandidate', async (data) => {
}
});
window.electronAPI.receive('disconnect', async (data) => {
peerConnection.close();
peerConnection = null;
});
// desktopCapturer 사용을 위해 preload 필요
// → 다음 단계에서 preload.js 설정