2 #include "FTPSession.h"
16 template <
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");
73 bool abort(CurrentOperation op) {
74 FTPLogger::writeLog(LOG_DEBUG,
"FTPSessionMgr",
"abort");
75 for (
int i = 0; i < FTP_MAX_SESSIONS; i++) {
76 if (sessions[i] !=
nullptr &&
77 sessions[i]->api().currentOperation() == op) {
78 return sessions[i]->api().abort();
87 for (
auto &
session : sessions) {
96 int count(CurrentOperation op) {
98 for (
auto &
session : sessions) {
99 if (
session !=
nullptr &&
session->api().currentOperation() == op) {
110 const char *username;
111 const char *password;
FTPSession This class manages the FTP session, including command and data connections....
Definition: FTPSession.h:17
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