Inching toward a functional DEV environment here. I was able to get the C++ Client to compile. Next step is to authenticate with my test server.
I copied the code from the C++ Client guide and ran the Start method. The logger reports back NError: CancelledByUser.
It’s possible there’s a problem with my Nakama/Docker install. But if that were the case I would expect an “unable to reach server” error or something, not a “CancelledByUser.” The fact that I get the same error when Docker isn’t running is telling.
Can anyone advise why the authentication is getting “CancelledByUser.” I’m certainly not cancelling it myself.
Below is the code I’m running (straight from the C++ Client Guide) and a screenshot of the result.
#include <iostream>
#include "nakama-cpp/Nakama.h"
using namespace Nakama;
using namespace std;
class NakamaSessionManager
{
public:
NakamaSessionManager()
{
NClientParameters parameters;
_client = createDefaultClient(parameters);
}
void start(const string& deviceId)
{
// to do: read session token from your storage
string sessionToken;
if (!sessionToken.empty())
{
// Lets check if we can restore a cached session.
auto session = restoreSession(sessionToken);
if (!session->isExpired())
{
// Session was valid and is restored now.
_session = session;
return;
}
}
auto successCallback = [this](NSessionPtr session)
{
_session = session;
// to do: save session token in your storage
std::cout << "session token: " << session->getAuthToken() << std::endl;
};
auto errorCallback = [](const NError& error)
{
};
_client->authenticateDevice(deviceId, opt::nullopt, opt::nullopt, {}, successCallback, errorCallback);
}
protected:
NClientPtr _client;
NSessionPtr _session;
};
int main()
{
NLogger::initWithConsoleSink(NLogLevel::Debug);
NakamaSessionManager MySession;
MySession.start("MyDeviceID");
}