mirror of
https://github.com/pavlobu/deskreen.git
synced 2025-06-01 07:10:09 -07:00
able to retreive signaling server port from main process
This commit is contained in:
parent
5e918e7675
commit
763c13c854
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@ -4,7 +4,7 @@
|
|||||||
{
|
{
|
||||||
"type": "node",
|
"type": "node",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "Electron: Main",
|
"name": "Deskreen: Main",
|
||||||
"protocol": "inspector",
|
"protocol": "inspector",
|
||||||
"runtimeExecutable": "yarn",
|
"runtimeExecutable": "yarn",
|
||||||
"runtimeArgs": ["start-main-debug"],
|
"runtimeArgs": ["start-main-debug"],
|
||||||
|
@ -1,13 +1,29 @@
|
|||||||
import React from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
import { ipcRenderer } from 'electron';
|
||||||
import routes from '../constants/routes.json';
|
import routes from '../constants/routes.json';
|
||||||
import styles from './Home.css';
|
import styles from './Home.css';
|
||||||
|
|
||||||
|
// import signalingServer from '../server/signalingServer';
|
||||||
|
|
||||||
export default function Home(): JSX.Element {
|
export default function Home(): JSX.Element {
|
||||||
|
const [signalingServerPort, setSignalingServerPort] = useState('0000');
|
||||||
|
|
||||||
|
// Example of how to get signaling server port from main process in renderer process
|
||||||
|
// following this practice, you can also get local server ip address
|
||||||
|
useEffect(() => {
|
||||||
|
ipcRenderer.on('sending-port-from-main', (event, message) => {
|
||||||
|
console.log(message);
|
||||||
|
setSignalingServerPort(message);
|
||||||
|
});
|
||||||
|
ipcRenderer.invoke('get-signaling-server-port');
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.container} data-tid="container">
|
<div className={styles.container} data-tid="container">
|
||||||
<h2>Home</h2>
|
<h2>Home</h2>
|
||||||
<Link to={routes.COUNTER}>to Counter</Link>
|
<Link to={routes.COUNTER}>to Counter</Link>
|
||||||
|
<h3>{`Signaling server is running on port: ${signalingServerPort}`}</h3>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
import 'core-js/stable';
|
import 'core-js/stable';
|
||||||
import 'regenerator-runtime/runtime';
|
import 'regenerator-runtime/runtime';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { app, BrowserWindow } from 'electron';
|
import { app, BrowserWindow, ipcMain } from 'electron';
|
||||||
import { autoUpdater } from 'electron-updater';
|
import { autoUpdater } from 'electron-updater';
|
||||||
import log from 'electron-log';
|
import log from 'electron-log';
|
||||||
import signalingServer from './server/signalingServer';
|
import signalingServer from './server/signalingServer';
|
||||||
@ -127,3 +127,13 @@ app.on('activate', () => {
|
|||||||
// dock icon is clicked and there are no other windows open.
|
// dock icon is clicked and there are no other windows open.
|
||||||
if (mainWindow === null) createWindow();
|
if (mainWindow === null) createWindow();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// TODO: get locale of app and load appropriate menu texts and app texts( ISO 3166 COUNTRY CODES )
|
||||||
|
console.log('\n\n\n\n\n\n GETTING OS LOCALE: ');
|
||||||
|
console.log(app.getLocaleCountryCode());
|
||||||
|
|
||||||
|
ipcMain.handle('get-signaling-server-port', () => {
|
||||||
|
console.log('printing port');
|
||||||
|
console.log(signalingServer.port);
|
||||||
|
mainWindow.webContents.send('sending-port-from-main', signalingServer.port);
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user