FtpSession constructor
FtpSession(
- Socket controlSocket, {
- String? username,
- String? password,
- required ServerType serverType,
- required LoggerHandler logger,
- String? startingDirectory,
Implementation
FtpSession(this.controlSocket,
{this.username,
this.password,
required this.sharedDirectories,
required this.serverType,
required this.logger,
String? startingDirectory})
: commandHandler = FTPCommandHandler(controlSocket, logger),
fileOperations = VirtualFileOperations(sharedDirectories) {
sendResponse('220 Welcome to the FTP server');
// Set the starting directory if provided
if (startingDirectory != null && fileOperations.exists(startingDirectory)) {
try {
fileOperations.changeDirectory(startingDirectory);
} catch (e) {
logger.generalLog('Failed to set starting directory: $e');
sendResponse('550 Failed to set starting directory');
}
}
controlSocket.listen(processCommand, onDone: closeConnection);
}