fix: possible eventemitter memory leak delected

do: io.setMaxListeners(0);
This commit is contained in:
yaofeng
2018-04-18 16:53:34 +08:00
parent e20dafbb66
commit 0997291484
3 changed files with 5 additions and 2 deletions

View File

@@ -9,7 +9,7 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageOutputPath>..\artifacts</PackageOutputPath>
<PackageId>ElectronNET.CLI</PackageId>
<Version>1.0.0</Version>
<Version>1.0.1</Version>
<Authors>Gregor Biswanger, Robert Muehsig</Authors>
<Product>Electron.NET</Product>
<Company />

View File

@@ -4,6 +4,7 @@ var electron_1 = require("electron");
module.exports = function (socket) {
socket.on('registerIpcMainChannel', function (channel) { // 监听主程序注册
electron_1.ipcMain.on(channel, function (event, args) { // 监听前端的推送
console.log('ipc emit...', 'global.elesocket', global.elesocket.id, channel);
global.elesocket.emit(channel, [event.preventDefault(), args]); // 发送到后端
});
});

View File

@@ -15,11 +15,13 @@ app.on('ready', () => {
function startSocketApiBridge(port) {
io = require('socket.io')(port);
// yf add
io.setMaxListeners(0);
startAspCoreBackend(port);
io.on('connection', (socket) => {
global.elesocket = socket;
console.log('ASP.NET Core Application connected...', 'global.elesocket', global.elesocket.id);
console.log('ASP.NET Core Application connected...', 'global.elesocket', global.elesocket.id, new Date());
appApi = require('./api/app')(socket, app);
browserWindows = require('./api/browserWindows')(socket);