refactor: rename SandboxManager to Sandbox
This commit is contained in:
parent
8b890fdffe
commit
0809eaca4e
@ -8,7 +8,7 @@ import { AIWorker } from "./AIWorker"
|
|||||||
|
|
||||||
import { ConnectionManager } from "./ConnectionManager"
|
import { ConnectionManager } from "./ConnectionManager"
|
||||||
import { DokkuClient } from "./DokkuClient"
|
import { DokkuClient } from "./DokkuClient"
|
||||||
import { Sandbox } from "./SandboxManager"
|
import { Sandbox } from "./Sandbox"
|
||||||
import { SecureGitClient } from "./SecureGitClient"
|
import { SecureGitClient } from "./SecureGitClient"
|
||||||
import { socketAuth } from "./socketAuth"; // Import the new socketAuth middleware
|
import { socketAuth } from "./socketAuth"; // Import the new socketAuth middleware
|
||||||
import { TFile, TFolder } from "./types"
|
import { TFile, TFolder } from "./types"
|
||||||
@ -109,13 +109,13 @@ io.on("connection", async (socket) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// Create or retrieve the sandbox manager for the given sandbox ID
|
// Create or retrieve the sandbox manager for the given sandbox ID
|
||||||
const sandboxManager = sandboxes[data.sandboxId] ?? new Sandbox(
|
const sandbox = sandboxes[data.sandboxId] ?? new Sandbox(
|
||||||
data.sandboxId,
|
data.sandboxId,
|
||||||
{
|
{
|
||||||
aiWorker, dokkuClient, gitClient,
|
aiWorker, dokkuClient, gitClient,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
sandboxes[data.sandboxId] = sandboxManager
|
sandboxes[data.sandboxId] = sandbox
|
||||||
|
|
||||||
// This callback recieves an update when the file list changes, and notifies all relevant connections.
|
// This callback recieves an update when the file list changes, and notifies all relevant connections.
|
||||||
const sendFileNotifications = (files: (TFolder | TFile)[]) => {
|
const sendFileNotifications = (files: (TFolder | TFile)[]) => {
|
||||||
@ -126,13 +126,13 @@ io.on("connection", async (socket) => {
|
|||||||
|
|
||||||
// Initialize the sandbox container
|
// Initialize the sandbox container
|
||||||
// The file manager and terminal managers will be set up if they have been closed
|
// The file manager and terminal managers will be set up if they have been closed
|
||||||
await sandboxManager.initialize(sendFileNotifications)
|
await sandbox.initialize(sendFileNotifications)
|
||||||
socket.emit("loaded", sandboxManager.fileManager?.files)
|
socket.emit("loaded", sandbox.fileManager?.files)
|
||||||
|
|
||||||
// Register event handlers for the sandbox
|
// Register event handlers for the sandbox
|
||||||
// For each event handler, listen on the socket for that event
|
// For each event handler, listen on the socket for that event
|
||||||
// Pass connection-specific information to the handlers
|
// Pass connection-specific information to the handlers
|
||||||
Object.entries(sandboxManager.handlers({
|
Object.entries(sandbox.handlers({
|
||||||
userId: data.userId,
|
userId: data.userId,
|
||||||
isOwner: data.isOwner,
|
isOwner: data.isOwner,
|
||||||
socket
|
socket
|
||||||
@ -156,7 +156,7 @@ io.on("connection", async (socket) => {
|
|||||||
// If the owner has disconnected from all sockets, close open terminals and file watchers.o
|
// If the owner has disconnected from all sockets, close open terminals and file watchers.o
|
||||||
// The sandbox itself will timeout after the heartbeat stops.
|
// The sandbox itself will timeout after the heartbeat stops.
|
||||||
if (data.isOwner && !connections.ownerIsConnected(data.sandboxId)) {
|
if (data.isOwner && !connections.ownerIsConnected(data.sandboxId)) {
|
||||||
await sandboxManager.disconnect()
|
await sandbox.disconnect()
|
||||||
socket.broadcast.emit(
|
socket.broadcast.emit(
|
||||||
"disableAccess",
|
"disableAccess",
|
||||||
"The sandbox owner has disconnected."
|
"The sandbox owner has disconnected."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user