diff --git a/src/main.tsx b/src/main.tsx
index ab2944396..09b366836 100644
--- a/src/main.tsx
+++ b/src/main.tsx
@@ -519,7 +519,7 @@ class MainSideBar extends React.Component<{}, {}> {
render() {
let model = GlobalModel;
- let curSessionId = model.curSessionId.get();
+ let activeSessionId = model.activeSessionId.get();
let session : Session = null;
return (
@@ -539,7 +539,7 @@ class MainSideBar extends React.Component<{}, {}> {
- this.handleSessionClick(session.sessionId)}>#{session.name.get()}
+ this.handleSessionClick(session.sessionId)}>#{session.name.get()}
New Session
diff --git a/src/model.ts b/src/model.ts
index a85f59780..dd54431a6 100644
--- a/src/model.ts
+++ b/src/model.ts
@@ -1,10 +1,10 @@
import * as mobx from "mobx";
import {sprintf} from "sprintf-js";
import {boundMethod} from "autobind-decorator";
-import {handleJsonFetchResponse} from "./util";
+import {handleJsonFetchResponse, base64ToArray} from "./util";
import {TermWrap} from "./term";
import {v4 as uuidv4} from "uuid";
-import type {SessionDataType, WindowDataType, LineType, RemoteType, HistoryItem, RemoteInstanceType, CmdDataType, FeCmdPacketType, TermOptsType, RemoteStateType, ScreenDataType, ScreenWindowType, ScreenOptsType, LayoutType} from "./types";
+import type {SessionDataType, WindowDataType, LineType, RemoteType, HistoryItem, RemoteInstanceType, CmdDataType, FeCmdPacketType, TermOptsType, RemoteStateType, ScreenDataType, ScreenWindowType, ScreenOptsType, LayoutType, PtyDataUpdateType} from "./types";
import {WSControl} from "./ws";
var GlobalUser = "sawka";
@@ -69,6 +69,14 @@ class Cmd {
}
}
+ updatePtyData(ptyMsg : PtyDataUpdateType) {
+ for (let key in this.instances) {
+ let tw = this.instances[key];
+ let data = base64ToArray(ptyMsg.ptydata64);
+ tw.updatePtyData(ptyMsg.ptypos, data);
+ }
+ }
+
getTermWrap(screenId : string, windowId : string) : TermWrap {
return this.instances[screenId + "/" + windowId];
}
@@ -183,6 +191,16 @@ class Screen {
return session.getWindowById(this.activeWindowId.get());
}
+ updatePtyData(ptyMsg : PtyDataUpdateType) {
+ for (let i=0; i
= {};
+ let activeWindowId = this.activeWindowId.get();
+ if (activeWindowId != null) {
+ GlobalModel.loadWindow(this.sessionId, activeWindowId, false);
+ loadedMap[activeWindowId] = true;
+ }
+ for (let i=0; i {
if (!isBlank(win.curremote)) {
@@ -430,7 +473,7 @@ class Session {
class Model {
clientId : string;
- curSessionId : OV = mobx.observable.box(null);
+ activeSessionId : OV = mobx.observable.box(null);
sessionListLoaded : OV = mobx.observable.box(false);
sessionList : OArr = mobx.observable.array([], {name: "SessionList", deep: false});
ws : WSControl;
@@ -460,11 +503,20 @@ class Model {
}
onWSMessage(message : any) {
+ if ("ptydata64" in message) {
+ let ptyMsg : PtyDataUpdateType = message;
+ let activeScreen = this.getActiveScreen();
+ if (!activeScreen || activeScreen.sessionId != ptyMsg.sessionid) {
+ return;
+ }
+ activeScreen.updatePtyData(ptyMsg);
+ return;
+ }
console.log("ws-message", message);
}
getActiveSession() : Session {
- return this.getSessionById(this.curSessionId.get());
+ return this.getSessionById(this.activeSessionId.get());
}
getSessionById(sessionId : string) : Session {
@@ -541,7 +593,7 @@ class Model {
if (session == null) {
return;
}
- let isActive = (win.sessionid == this.curSessionId.get());
+ let isActive = (win.sessionid == this.activeSessionId.get());
session.updateWindow(win, isActive);
}
@@ -562,10 +614,11 @@ class Model {
}
this.sessionList.replace(slist);
this.sessionListLoaded.set(true)
- this.curSessionId.set(defaultSessionId);
- let win = this.getActiveWindow();
- if (win != null) {
- this.loadWindow(win.sessionId, win.windowId);
+ this.activeSessionId.set(defaultSessionId);
+ let screen = this.getActiveScreen();
+ if (screen != null) {
+ this.ws.pushMessage({type: "watchscreen", sessionid: screen.sessionId, screenid: screen.screenId});
+ screen.loadWindows(false);
}
})();
}).catch((err) => {
@@ -573,7 +626,7 @@ class Model {
});
}
- loadWindow(sessionId : string, windowId : string) {
+ loadWindow(sessionId : string, windowId : string, force : boolean) {
let usp = new URLSearchParams({sessionid: sessionId, windowid: windowId});
let url = new URL(sprintf("http://localhost:8080/api/get-window?") + usp.toString());
fetch(url).then((resp) => handleJsonFetchResponse(url, resp)).then((data) => {
diff --git a/src/types.ts b/src/types.ts
index cba9380cf..567c28c72 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -108,7 +108,13 @@ type FeCmdPacketType = {
userid : string,
cmdstr : string,
remotestate : CmdRemoteStateType,
-}
+};
+
+type WatchScreenPacketType = {
+ type : string,
+ sessionid : string,
+ screenid : string,
+};
type TermOptsType = {
rows : number,
@@ -147,4 +153,12 @@ type CmdDataType = {
usedrows : number,
};
-export type {SessionDataType, LineType, RemoteType, RemoteStateType, RemoteInstanceType, WindowDataType, HistoryItem, CmdRemoteStateType, FeCmdPacketType, TermOptsType, CmdStartPacketType, CmdDonePacketType, CmdDataType, ScreenDataType, ScreenOptsType, ScreenWindowType, LayoutType};
+type PtyDataUpdateType = {
+ sessionid : string,
+ cmdid : string,
+ ptypos : number,
+ ptydata64 : string,
+ ptydatalen : number,
+};
+
+export type {SessionDataType, LineType, RemoteType, RemoteStateType, RemoteInstanceType, WindowDataType, HistoryItem, CmdRemoteStateType, FeCmdPacketType, TermOptsType, CmdStartPacketType, CmdDonePacketType, CmdDataType, ScreenDataType, ScreenOptsType, ScreenWindowType, LayoutType, PtyDataUpdateType};
diff --git a/src/util.ts b/src/util.ts
index 29b3bf100..c43f0b817 100644
--- a/src/util.ts
+++ b/src/util.ts
@@ -33,4 +33,13 @@ function handleJsonFetchResponse(url : URL, resp : any) : Promise {
return rtnData;
}
-export {handleJsonFetchResponse};
+function base64ToArray(b64 : string) : Uint8Array {
+ let rawStr = atob(b64);
+ let rtnArr = new Uint8Array(new ArrayBuffer(rawStr.length));
+ for (let i=0; i