Skip to content

Commit

Permalink
Revert "Merge branch 'issue/5694' into develop-hw"
Browse files Browse the repository at this point in the history
This reverts commit a0124bc, reversing
changes made to b34f841.
  • Loading branch information
조현욱[SW교육플랫폼개발] authored and Tnks2U committed Sep 25, 2024
1 parent 38b4aad commit 2a11437
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 58 deletions.
Binary file modified app/server/win/server.exe
Binary file not shown.
86 changes: 37 additions & 49 deletions app/src/main/electron/serverProcessManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ServerProcessManager {
} catch (e) {
logger.error('Error occurred while spawn Server Process.', e);
throw new Error(
'Error occurred while spawn Server Process. make sure it exists same dir path'
'Error occurred while spawn Server Process. make sure it exists same dir path',
);
}
}
Expand All @@ -38,7 +38,7 @@ class ServerProcessManager {

open() {
this._receiveFromChildEventRegister();
this._sendToChild('open', process.env.NODE_ENV);
this._sendToChild('open');
// this.childProcess.open();
}

Expand All @@ -52,14 +52,6 @@ class ServerProcessManager {
this._sendToChild('addRoomId', roomId);
}

connectHardwareSuccess() {
this._sendToChild('connectHardwareSuccess');
}

connectHardwareFailed() {
this._sendToChild('connectHardwareFailed');
}

disconnectHardware() {
// this.childProcess.disconnectHardware();
this._sendToChild('disconnectHardware');
Expand All @@ -76,11 +68,10 @@ class ServerProcessManager {
* @private
*/
_sendToChild(methodName: string, message?: any) {
this._isProcessLive() &&
this.childProcess.send({
key: methodName,
value: message,
});
this._isProcessLive() && this.childProcess.send({
key: methodName,
value: message,
});
}

_receiveFromChildEventRegister() {
Expand All @@ -96,46 +87,43 @@ class ServerProcessManager {
// this.childProcess.on('close', () => {

// });
this.childProcess &&
this.childProcess.on('message', (message: { key: string; value: any }) => {
const { key, value } = message;
switch (key) {
case 'cloudModeChanged': {
this.router.notifyCloudModeChanged(value);
break;
}
case 'runningModeChanged': {
this.router.notifyServerRunningModeChanged(value);
break;
}
case 'data': {
this.router.handleServerData(value);
break;
}
case 'connection': {
this.router.handleServerSocketConnected();
break;
}
case 'close': {
if (!this.currentRoomId || this.currentRoomId === value) {
this.router.handleServerSocketClosed();
}
break;
}
default: {
console.error('unhandled pkg server message', key, value);
}
this.childProcess && this.childProcess.on('message', (message: { key: string; value: any; }) => {
const { key, value } = message;
switch (key) {
case 'cloudModeChanged': {
this.router.notifyCloudModeChanged(value);
break;
}
case 'runningModeChanged': {
this.router.notifyServerRunningModeChanged(value);
break;
}
case 'data': {
this.router.handleServerData(value);
break;
}
case 'connection': {
this.router.handleServerSocketConnected();
break;
}
case 'close': {
if (!this.currentRoomId || this.currentRoomId === value) {
this.router.handleServerSocketClosed();
}
});
break;
}
default: {
console.error('unhandled pkg server message', key, value);
}
}
});
}

_isProcessLive() {
return (
this.childProcess &&
return this.childProcess &&
!this.childProcess.killed &&
this.childProcess.connected &&
this.childProcess.channel
);
this.childProcess.channel;
}
}

Expand Down
12 changes: 3 additions & 9 deletions app/src/main/mainRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ interface IEntryServer {
setRouter: (router: MainRouter) => void;
open: () => void;
disconnectHardware: () => void;
connectHardwareSuccess: () => void;
connectHardwareFailed: () => void;
addRoomIdsOnSecondInstance: (roomId: string) => void;
send: (data: any) => void;
}
Expand Down Expand Up @@ -242,7 +240,7 @@ class MainRouter {
if (connector) {
logger.info(
`[Device Info] ${config.id} | ${
config?.name?.ko || config?.name?.en || 'noname'
config?.name?.ko || config?.name?.en || 'noname'
}`
);
this.connector = connector;
Expand All @@ -253,7 +251,6 @@ class MainRouter {
} catch (e) {
logger.error(`startScan Error, ${e.name} ${e.message}`);
this.sendState(HardwareStatement.scanFailed);
this.server.connectHardwareFailed();
}
}

Expand Down Expand Up @@ -320,7 +317,6 @@ class MainRouter {
logger.verbose('entryServer, connector connection');
this.handler = new DataHandler(this.config.id);
this._connectToServer();
this.server.connectHardwareSuccess();
this.connector.connect(); // router 설정 후 실제 기기와의 통신 시작
}
}
Expand Down Expand Up @@ -549,7 +545,7 @@ class MainRouter {
console.log(e);
return false;
}
});
})
ipcMain.on('getSharedObject', (e) => {
e.returnValue = global.sharedObject;
});
Expand All @@ -561,9 +557,7 @@ class MainRouter {
}
});
ipcMain.on('customButtonClicked', (e, key) => {
this.hwModule &&
this.hwModule.customButtonClicked &&
this.hwModule.customButtonClicked(key);
this.hwModule && this.hwModule.customButtonClicked && this.hwModule.customButtonClicked(key);
});
logger.verbose('EntryHW ipc event registered');
}
Expand Down

0 comments on commit 2a11437

Please sign in to comment.