#include <iostream>
{
int read(char *buf, int count) override { return posixRead(buf, count); }
void write(const char *buf, size_t count) override
{
posixWriteBuffered(buf, count);
}
void flush() override { posixFlush(); }
void listReply(
std::vector<PdCom::Variable> vars,
std::vector<std::string> ) override
{
for (const auto &v : vars)
std::cout << "Found var " << v.getPath() << "\n";
running_ = false;
}
void connected() override
{
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"; }
std::string getPassword() override { return "test"; }
using Sasl::logout;
using SimpleLoginManager::login;
void completed(LoginResult result) override
{
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
Base class for PdCom protocol handler.
Definition Process.h:87
Wrapper for Cyrus SASL library.
Definition SimpleLoginManager.h:58
static void InitLibrary(const char *plugin_path=nullptr)
Sasl global initialization.