Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/common/BaseClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#include <nakama-cpp/log/NLogger.h>
#include <nakama-cpp/realtime/NWebsocketsFactory.h>

#include <optional>
#include <future>
#include <optional>
#include <vector>

namespace Nakama {
Expand Down
45 changes: 16 additions & 29 deletions core/common/BaseClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,17 @@ class BaseClient : public NClientInterface {
bool create,
const NStringMap& vars) override;

std::future<NSessionPtr> authenticateAppleAsync(
const std::string& token,
const std::string& username,
bool create,
const NStringMap& vars) override;
std::future<NSessionPtr>
authenticateAppleAsync(const std::string& token, const std::string& username, bool create, const NStringMap& vars)
override;

std::future<NSessionPtr> authenticateCustomAsync(
const std::string& id,
const std::string& username,
bool create,
const NStringMap& vars) override;
std::future<NSessionPtr>
authenticateCustomAsync(const std::string& id, const std::string& username, bool create, const NStringMap& vars)
override;

std::future<NSessionPtr> authenticateSteamAsync(
const std::string& token,
const std::string& username,
bool create,
const NStringMap& vars) override;
std::future<NSessionPtr>
authenticateSteamAsync(const std::string& token, const std::string& username, bool create, const NStringMap& vars)
override;

std::future<NSessionPtr> authenticateRefreshAsync(NSessionPtr session, const NStringMap& vars) override;

Expand Down Expand Up @@ -149,10 +143,8 @@ class BaseClient : public NClientInterface {

std::future<void> unlinkCustomAsync(NSessionPtr session, const std::string& id) override;

std::future<void> importFacebookFriendsAsync(
NSessionPtr session,
const std::string& token,
const std::optional<bool>& reset) override;
std::future<void>
importFacebookFriendsAsync(NSessionPtr session, const std::string& token, const std::optional<bool>& reset) override;

std::future<NAccount> getAccountAsync(NSessionPtr session) override;

Expand Down Expand Up @@ -225,8 +217,7 @@ class BaseClient : public NClientInterface {
std::future<void> leaveGroupAsync(NSessionPtr session, const std::string& groupId) override;

std::future<NGroupListPtr>
listGroupsAsync(NSessionPtr session, const std::string& name, int32_t limit, const std::string& cursor)
override;
listGroupsAsync(NSessionPtr session, const std::string& name, int32_t limit, const std::string& cursor) override;

std::future<NUserGroupListPtr> listUserGroupsAsync(
NSessionPtr session,
Expand Down Expand Up @@ -355,15 +346,11 @@ class BaseClient : public NClientInterface {
std::future<void>
deleteStorageObjectsAsync(NSessionPtr session, const std::vector<NDeleteStorageObjectId>& objectIds) override;

std::future<NRpc> rpcAsync(
NSessionPtr session,
const std::string& id,
const std::optional<std::string>& payload) override;
std::future<NRpc>
rpcAsync(NSessionPtr session, const std::string& id, const std::optional<std::string>& payload) override;

std::future<NRpc> rpcAsync(
const std::string& http_key,
const std::string& id,
const std::optional<std::string>& payload) override;
std::future<NRpc>
rpcAsync(const std::string& http_key, const std::string& id, const std::optional<std::string>& payload) override;

protected:
int _port = -1;
Expand Down
4 changes: 2 additions & 2 deletions core/common/StrUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
#include "StrUtil.h"
#include <google/protobuf/stubs/strutil.h>

#include <sstream>
#include <regex>
#include <optional>
#include <regex>
#include <sstream>

namespace Nakama {

Expand Down
2 changes: 1 addition & 1 deletion core/core-rest/RestClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
#include <rapidjson/stringbuffer.h>
#include <rapidjson/writer.h>

#include <functional>
#include <optional>
#include <string>
#include <vector>
#include <functional>

#undef NMODULE_NAME
#define NMODULE_NAME "Nakama::RestClient"
Expand Down
4 changes: 2 additions & 2 deletions core/core-rest/RestClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

#include "../common/BaseClient.h"
#include <google/protobuf/message.h>
#include <set>
#include <optional>
#include <vector>
#include <set>
#include <string>
#include <vector>

namespace Nakama {

Expand Down
2 changes: 1 addition & 1 deletion core/core-rt/NRtClientProtocolInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

#pragma once

#include <google/protobuf/message.h>
#include "nakama-cpp/NTypes.h"
#include <google/protobuf/message.h>

namespace Nakama {

Expand Down
71 changes: 37 additions & 34 deletions core/src/log/NConsoleLogSink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,64 +14,67 @@
* limitations under the License.
*/

#include <nakama-cpp/log/NConsoleLogSink.h>
#include <iostream>
#include <nakama-cpp/log/NConsoleLogSink.h>
#ifdef __ANDROID__
#include <android/log.h>
#endif

#ifdef WIN32
#include <Windows.h>
#include <Windows.h>
#endif

namespace Nakama {

using namespace std;
using namespace std;

#ifdef __ANDROID__
static android_LogPriority androidLogPrio(NLogLevel level) {
switch (level) {
case NLogLevel::Fatal: return ANDROID_LOG_FATAL;
case NLogLevel::Error: return ANDROID_LOG_ERROR;
case NLogLevel::Warn: return ANDROID_LOG_WARN;
case NLogLevel::Info: return ANDROID_LOG_INFO;
case NLogLevel::Debug: return ANDROID_LOG_DEBUG;
default: return ANDROID_LOG_UNKNOWN;
}
}
static android_LogPriority androidLogPrio(NLogLevel level) {
switch (level) {
case NLogLevel::Fatal:
return ANDROID_LOG_FATAL;
case NLogLevel::Error:
return ANDROID_LOG_ERROR;
case NLogLevel::Warn:
return ANDROID_LOG_WARN;
case NLogLevel::Info:
return ANDROID_LOG_INFO;
case NLogLevel::Debug:
return ANDROID_LOG_DEBUG;
default:
return ANDROID_LOG_UNKNOWN;
}
}
#endif

void NConsoleLogSink::log(NLogLevel level, const std::string& message, const char* func)
{
std::string tmp;
void NConsoleLogSink::log(NLogLevel level, const std::string& message, const char* func) {
std::string tmp;

if (func && func[0])
{
tmp.append("[").append(func).append("] ");
}
if (func && func[0]) {
tmp.append("[").append(func).append("] ");
}

tmp.append(message).append("\n");
tmp.append(message).append("\n");

#ifdef __ANDROID__
__android_log_print(androidLogPrio(level), "nakama", "%s", message.c_str());
__android_log_print(androidLogPrio(level), "nakama", "%s", message.c_str());
#else
// write to console
std::ostream& os = (level >= NLogLevel::Error) ? std::cerr : std::cout;
os << tmp;
// write to console
std::ostream& os = (level >= NLogLevel::Error) ? std::cerr : std::cout;
os << tmp;
#endif

#ifdef WIN32
// write debug string so Visual Studio and DebugView will catch it
OutputDebugStringA(tmp.c_str());
// write debug string so Visual Studio and DebugView will catch it
OutputDebugStringA(tmp.c_str());
#endif
}
}

void NConsoleLogSink::flush()
{
void NConsoleLogSink::flush() {
#if !defined(__ANDROID__)
std::cout.flush();
std::cerr.flush();
std::cout.flush();
std::cerr.flush();
#endif
}

}

} // namespace Nakama
Loading
Loading