Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
louislam committed Dec 25, 2023
1 parent 789a034 commit 532bb6e
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions backend/agent-socket-handlers/terminal-socket-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { AgentSocketHandler } from "../agent-socket-handler";
import { AgentSocket } from "../../common/agent-socket";

export class TerminalSocketHandler extends AgentSocketHandler {
create(s : DockgeSocket, server : DockgeServer, agentSocket : AgentSocket) {
create(socket : DockgeSocket, server : DockgeServer, agentSocket : AgentSocket) {

agentSocket.on("terminalInput", async (terminalName : unknown, cmd : unknown, callback) => {
try {
checkLogin(s);
checkLogin(socket);

if (typeof(terminalName) !== "string") {
throw new Error("Terminal name must be a string.");
Expand All @@ -36,7 +36,7 @@ export class TerminalSocketHandler extends AgentSocketHandler {
// Main Terminal
agentSocket.on("mainTerminal", async (terminalName : unknown, callback) => {
try {
checkLogin(s);
checkLogin(socket);

// TODO: Reset the name here, force one main terminal for now
terminalName = "console";
Expand All @@ -55,7 +55,7 @@ export class TerminalSocketHandler extends AgentSocketHandler {
log.debug("mainTerminal", "Terminal created");
}

terminal.join(s);
terminal.join(socket);
terminal.start();

callbackResult({
Expand All @@ -69,7 +69,7 @@ export class TerminalSocketHandler extends AgentSocketHandler {
// Interactive Terminal for containers
agentSocket.on("interactiveTerminal", async (stackName : unknown, serviceName : unknown, shell : unknown, callback) => {
try {
checkLogin(s);
checkLogin(socket);

if (typeof(stackName) !== "string") {
throw new ValidationError("Stack name must be a string.");
Expand All @@ -88,7 +88,7 @@ export class TerminalSocketHandler extends AgentSocketHandler {

// Get stack
const stack = await Stack.getStack(server, stackName);
stack.joinContainerTerminal(s, serviceName, shell);
stack.joinContainerTerminal(socket, serviceName, shell);

callbackResult({
ok: true,
Expand All @@ -106,7 +106,7 @@ export class TerminalSocketHandler extends AgentSocketHandler {
}

try {
checkLogin(s);
checkLogin(socket);
if (typeof(terminalName) !== "string") {
throw new ValidationError("Terminal name must be a string.");
}
Expand All @@ -129,7 +129,7 @@ export class TerminalSocketHandler extends AgentSocketHandler {
// Leave Combined Terminal
agentSocket.on("leaveCombinedTerminal", async (stackName : unknown, callback) => {
try {
checkLogin(s);
checkLogin(socket);

log.debug("leaveCombinedTerminal", "Stack name: " + stackName);

Expand All @@ -138,7 +138,7 @@ export class TerminalSocketHandler extends AgentSocketHandler {
}

const stack = await Stack.getStack(server, stackName);
await stack.leaveCombinedTerminal(s);
await stack.leaveCombinedTerminal(socket);

callbackResult({
ok: true,
Expand All @@ -152,7 +152,7 @@ export class TerminalSocketHandler extends AgentSocketHandler {
agentSocket.on("terminalResize", async (terminalName: unknown, rows: unknown, cols: unknown) => {
log.info("terminalResize", `Terminal: ${terminalName}`);
try {
checkLogin(s);
checkLogin(socket);
if (typeof terminalName !== "string") {
throw new Error("Terminal name must be a string.");
}
Expand Down

0 comments on commit 532bb6e

Please sign in to comment.