Closed Jump-Suit closed 4 years ago
Cannot reproduce. Here's my minimal example code:
#include <chrono>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <thread>
#include "files/discord.h"
namespace {
volatile bool interrupted{ false };
}
void main()
{
using namespace std::chrono_literals;
discord::Core* core;
auto result = discord::Core::Create(426958487654891521, DiscordCreateFlags_Default, &core);
core->LobbyManager().OnMemberUpdate.Connect([&core](std::int64_t LobbyId, std::int64_t UserId) {
std::cout << "lobby " << LobbyId << ", user " << UserId << " was updated\n";
char metadata[4096]{ 0 };
core->LobbyManager().GetMemberMetadataValue(LobbyId, UserId, "mmr", metadata);
std::cout << "\nUser MMR Is: " << metadata;
});
discord::LobbyTransaction CreateTxn;
core->LobbyManager().GetLobbyCreateTransaction(&CreateTxn);
CreateTxn.SetLocked(false);
CreateTxn.SetType(discord::LobbyType::Public);
core->LobbyManager().CreateLobby(CreateTxn, [&core](discord::Result result, const discord::Lobby& lobby) {
discord::LobbyMemberTransaction UpdateTxn;
core->LobbyManager().GetMemberUpdateTransaction(lobby.GetId(), 53908232506183680, &UpdateTxn);
UpdateTxn.SetMetadata("mmr", "1337");
core->LobbyManager().UpdateMember(lobby.GetId(), 53908232506183680, UpdateTxn, [=](discord::Result result) {
std::cout << (result == discord::Result::Ok);
});
});
int m = 0;
while (true)
{
// run callbacks
core->RunCallbacks();
m++;
std::this_thread::sleep_for(100ms);
}
}
If you can paste a sample code that repros, I can take a look.
Transferred from Developer Feedback Website:
Amazzj:
Hi there!
I think I've found a strange behaviour with the Member Metadata feature in the lobbyManager. Setting the metadata is fine, and the sdk returns a Result.Ok, but then when calling MemberMetadataCount, the result is always 0 and there is no metadata attached to the user. So the feature is unusable right now :/
Here is some sample code to reproduce the error (sorry, don't know how to format it):
var txn = lobbyManager.GetMemberUpdateTransaction(lobbyId, userId);
txn.SetMetadata("foo", "bar");
lobbyManager.UpdateMember(lobbyId, userId, txn, (result) =>
{
}
The code used to read the value:
try
{
}
catch (Discord.ResultException)
{
}
And I always hit the error, no matter what I try, I never read the correct value :(
PS : There is also a problem with the doc, the example for the LobbyMemberTransaction.SetMetadata function uses GetMemberUpdateTransaction() without arguments but this function does not exist.