refactor: update ref

This commit is contained in:
Mauricio Siu 2024-10-05 18:42:08 -06:00
parent 4cde1a8a7d
commit 651bf3a303
2 changed files with 13 additions and 3 deletions

View File

@ -21,13 +21,21 @@ export const DockerLogsId: React.FC<Props> = ({
const wsRef = useRef<WebSocket | null>(null); // Ref to hold WebSocket instance
useEffect(() => {
if (containerId === "select-a-containe") {
return;
}
// if (containerId === "select-a-container") {
// return;
// }
const container = document.getElementById(id);
if (container) {
container.innerHTML = "";
}
if (wsRef.current) {
console.log(wsRef.current);
if (wsRef.current.readyState === WebSocket.OPEN) {
wsRef.current.close();
}
wsRef.current = null;
}
const termi = new Terminal({
cursorBlink: true,
cols: 80,

View File

@ -33,6 +33,8 @@ export const setupDockerContainerLogsWebSocketServer = (
const tail = url.searchParams.get("tail");
const serverId = url.searchParams.get("serverId");
const { user, session } = await validateWebSocketRequest(req);
console.log(wssTerm.clients);
console.log(wssTerm.clients.size);
if (!containerId) {
ws.close(4000, "containerId no provided");