-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
41 lines (34 loc) · 1012 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const { app, BrowserWindow } = require('electron')
const wsl = require('ws')
app.disableHardwareAcceleration()
app.commandLine.appendSwitch('force-device-scale-factor', '1');
let win
app.once('ready', () => {
win = new BrowserWindow({
show: false,
frame: false,
width: 1920,
height: 1080,
webPreferences: {
offscreen: true,
transparent: true
}
})
let counter = 0;
let wss = new wsl.Server({ port: 8080 });
let ws = null;
let sent = true;
win.loadURL('https://app.singular.live/output/3KTkvd53TvQHZ95Q4Bg0Ld/Default?aspect=16:9')
// win.webContents.enableDeviceEmulation({ screenSize: { width: 1920, height: 1080 }, viewSize: { width: 1920, height: 1080 }});
win.webContents.on('paint', (event, dirty, image) => {
console.log(counter++, dirty, image.getBitmap().length)
if (ws && sent) {
sent = false;
ws.send(image.toBitmap(), () => { sent = true; });
}
})
win.webContents.setFrameRate(50)
wss.on('connection', (webby) => {
ws = webby;
})
})