#include <iostream>
{
int read(
char *buf,
int count)
override {
return posixRead(buf, count); }
void write(
const char *buf,
size_t count)
override
{
}
std::vector<PdCom::Variable> vars,
std::vector<std::string> ) override
{
for (const auto &v : vars)
std::cout << "Found var " << v.getPath() << "\n";
running_ = false;
}
{
std::cout << "Connected!" << std::endl;
connected_ = true;
}
public:
MyProcess(const char *host = "127.0.0.1") :
{}
using Process::list;
using Process::setAuthManager;
bool running_ = true;
bool connected_ = false;
};
{
public:
MyProcess *p_ = nullptr;
MyAuthManager() : PdCom::SimpleLoginManager("localhost") {}
std::string
getAuthname()
override {
return "bjarne"; }
using Sasl::logout;
using SimpleLoginManager::login;
{
std::cout << "completed: " << static_cast<int>(result) << std::endl;
if (result == LoginResult::Success) {
p_->list("");
}
}
};
int main()
{
MyAuthManager am;
MyProcess p;
p.setAuthManager(&am);
am.p_ = &p;
while (!p.connected_)
p.asyncData();
am.login();
while (p.running_) {
p.asyncData();
}
am.logout();
p.asyncData();
return 0;
}
Wrapper around POSIX socket.
Definition PosixProcess.h:44
void posixFlush()
Flush internal buffer to socket.
void posixWriteBuffered(const char *buf, size_t count)
Buffered Wrapper for write().
int posixRead(char *buf, int count)
Wrapper for read().
Base class for PdCom protocol handler.
Definition Process.h:87
virtual void write(const char *buf, size_t count)=0
Write data to server.
virtual int read(char *buf, int count)=0
Read data from server.
virtual void connected()=0
Protocol initialization completed.
virtual void flush()=0
Flush unsent data in output buffer.
virtual void listReply(std::vector< Variable > variables, std::vector< std::string > dirs)
Reply to list() call.
Wrapper for Cyrus SASL library.
Definition SimpleLoginManager.h:58
virtual std::string getPassword()
Callback to get password.
Definition SimpleLoginManager.h:134
virtual std::string getAuthname()
Callback to get login name.
Definition SimpleLoginManager.h:131
static void InitLibrary(const char *plugin_path=nullptr)
Sasl global initialization.
virtual void completed(LoginResult result)=0
Authentification completed callback.