pass process id as client id to ws

This commit is contained in:
sawka 2022-07-12 13:20:10 -07:00
parent 28f5e9bf05
commit 7867edb8da
2 changed files with 12 additions and 37 deletions

View File

@ -75,7 +75,8 @@ app.on('window-all-closed', () => {
});
electron.ipcMain.on("get-id", (event) => {
return event.processId;
event.returnValue = event.processId;
return;
});

View File

@ -16,6 +16,15 @@ function isBlank(s : string) {
return (s == null || s == "");
}
type ElectronApi = {
getId : () => string,
onCmdT : (callback : () => void) => void,
};
function getApi() : ElectronApi {
return (window as any).api;
}
class Cmd {
sessionId : string;
windowId : string;
@ -391,7 +400,7 @@ class Model {
remotesLoaded : OV<boolean> = mobx.observable.box(false);
constructor() {
this.clientId = uuidv4();
this.clientId = getApi().getId();
this.loadRemotes();
this.loadSessionList();
this.ws = new WSControl(this.clientId, this.onWSMessage.bind(this))
@ -575,38 +584,3 @@ GlobalModel = (window as any).GlobalModel;
export {Model, Session, Window, GlobalModel, Cmd};
// GlobalWS.registerAndSendGetCmd(getCmdPacket, (dataPacket) => {
// let realData = atob(dataPacket.ptydata64);
// this.updatePtyData(this.ptyPos, realData, dataPacket.ptydatalen);
// });
/*
reloadTerminal(startTail : boolean, delayMs : number) {
loadPtyOut(this.terminal, this.sessionId, this.cmdId, delayMs, (ptyoutLen) => {
mobx.action(() => {
this.incRenderVersion();
this.ptyPos = ptyoutLen;
})();
if (startTail) {
this.startPtyTail();
}
});
}
setCmdStatus(status : string) {
if (this.cmdStatus == status) {
return;
}
this.cmdStatus = status;
if (!this.isRunning() && this.tailReqId) {
this.stopPtyTail();
}
}
}
isRunning() : boolean {
return this.cmdStatus == "running" || this.cmdStatus == "detached";
}
*/