16template <
class ClientType>
19 FTPSessionMgr() { FTPLogger::writeLog(LOG_DEBUG,
"FTPSessionMgr"); }
22 FTPLogger::writeLog(LOG_DEBUG,
"~FTPSessionMgr");
27 bool begin(IPAddress &address,
int port,
const char *username,
28 const char *password) {
29 FTPLogger::writeLog(LOG_DEBUG,
"FTPSessionMgr",
"createSession");
30 this->address = address;
32 this->username = username;
33 this->password = password;
38 FTPLogger::writeLog(LOG_DEBUG,
"FTPSessionMgr",
"end");
39 for (
int i = 0; i < FTP_MAX_SESSIONS; i++) {
40 if (sessions[i] !=
nullptr) {
45 sessions[i] =
nullptr;
52 for (
int i = 0; i < FTP_MAX_SESSIONS; i++) {
53 if (sessions[i] ==
nullptr) {
55 if (sessions[
i]->
begin(address, port, username, password)) {
59 sessions[
i] =
nullptr;
61 }
else if (sessions[
i]->api().currentOperation() == NOP) {
66 FTPLogger::writeLog(LOG_ERROR,
"FTPSessionMgr",
"No available sessions");
74 FTPLogger::writeLog(LOG_DEBUG,
"FTPSessionMgr",
"abort");
76 if (sessions[
i] !=
nullptr &&
77 sessions[
i]->api().currentOperation() ==
op) {
78 return sessions[
i]->
api().abort();
87 for (
auto &
session : sessions) {
98 for (
auto &
session : sessions) {
110 const char *username;
111 const char *password;
FTPSession This class manages the FTP session, including command and data connections....
Definition FTPSession.h:17
FTPBasicAPI & api()
Returns the access to the basic API.
Definition FTPSession.h:42
void setValid(bool valid)
Used to set as invalid for dummy error session.
Definition FTPSession.h:48
FTPSessionMgr This class manages multiple FTP sessions, allowing for concurrent operations and sessio...
Definition FTPSessionMgr.h:17
int count(CurrentOperation op)
Count the sessions with a specific current operation.
Definition FTPSessionMgr.h:96
int count()
Count the sessions.
Definition FTPSessionMgr.h:85
bool abort(CurrentOperation op)
Aborts the current operation in all sessions.
Definition FTPSessionMgr.h:73
bool begin(IPAddress &address, int port, const char *username, const char *password)
Initializes the session manager with the FTP server details.
Definition FTPSessionMgr.h:27
FTPSession< ClientType > & session()
Provides a session for the FTP operations.
Definition FTPSessionMgr.h:51