diff --git a/cast/app.js b/cast/app.js
index 19e05f1..b826c38 100644
--- a/cast/app.js
+++ b/cast/app.js
@@ -8,6 +8,7 @@ var sessions = [];
var clickCount = 0;
var TID = 0;
const MAX_LINES = 9999999;
+const status = document.getElementById("status");
let socket;
const generateSSID = () => (
@@ -74,11 +75,15 @@ const focusStyle = (tid) => {
tablink.style.color = "white";
logger.style.display = "block";
document.getElementById(tab.ssid).style.display = "none";
+ status.innerHTML =
+ 'tab disconnected';
}
else {
tablink.classList.add('active');
logger.style.display = "none";
document.getElementById(tab.ssid).style.display = "block";
+ status.innerHTML =
+ 'connected';
}
console.log("Session ID: " + getTabByTID(tid).ssid);
}
@@ -86,17 +91,19 @@ const focusStyle = (tid) => {
const openSession = (tid) => {
let tab = getTabByTID(tid);
focusStyle(tid);
- console.log(tab.ssid);
- // currentSession = tab.session;
currentSsid = tab.session.ssid;
- // document.getElementById(tab.ssid).style.display = "block";
- console.log(`openSession:: ${JSON.stringify(currentSsid)}`)
- if (socket) {
- // To register new session on WebSocket server
- socket.emit("new-session", { session_id: currentSsid });
-
- // To mark current tab as the current session on WebSocket server
- socket.emit("client-input", { input: '', session_id: currentSsid })
+ if(closedTabs.includes(tid)){
+ console.log(socket);
+ console.log("This session is closed");
+ } else {
+ console.log(`openSession:: ${JSON.stringify(currentSsid)}`)
+ if (socket) {
+ // To register new session on WebSocket server
+ socket.emit("new-session", { session_id: currentSsid });
+
+ // To mark current tab as the current session on WebSocket server
+ socket.emit("client-input", { input: '', session_id: currentSsid })
+ }
}
}
@@ -272,7 +279,6 @@ function downloadLog(ssid = currentSsid) {
socket = io.connect("/cast", { query: `session_id=${currentSsid}` });
-const status = document.getElementById("status");
socket.on("client-output", (data) => {
let ssid = data.ssid;
diff --git a/cast/app.py b/cast/app.py
index 4e0dace..b454298 100644
--- a/cast/app.py
+++ b/cast/app.py
@@ -141,7 +141,6 @@ def connect(data=None):
print("connect: task started")
-
@socketio.on("client-input", namespace="/cast")
def client_input(data):
# Update current session