Created
April 28, 2020 21:15
-
-
Save msciotti/be645f5b72edcfe1d827f07a55b5b499 to your computer and use it in GitHub Desktop.
Lobby Member Update Bug Repro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using Discord; | |
public class DiscordController : MonoBehaviour { | |
public Discord.Discord discord; | |
// Use this for initialization | |
void Start () { | |
discord = new Discord.Discord(461618159171141643, (System.UInt64)Discord.CreateFlags.Default); | |
var lobbyManager = discord.GetLobbyManager(); | |
lobbyManager.OnMemberUpdate += (lobbyId, userId) => | |
{ | |
Debug.Log("user " + userId + "got updated"); | |
}; | |
// Hardcode activitySecret received from player2, and player 1 user id | |
lobbyManager.ConnectLobbyWithActivitySecret("704801817720258571:61aa991176982f7b", (Discord.Result res, ref Discord.Lobby lobby) => | |
{ | |
if (res == Discord.Result.Ok) | |
{ | |
Debug.Log("Lobby: " + lobby.Id); | |
var txn = lobbyManager.GetMemberUpdateTransaction(lobby.Id, 53908232506183680); | |
txn.SetMetadata("current_mmr", "4267"); | |
lobbyManager.UpdateMember(lobby.Id, 53908232506183680, txn, (x) => | |
{ | |
Debug.Log("Updated the person"); | |
}); | |
} | |
}); | |
} | |
// Update is called once per frame | |
void Update () { | |
discord.RunCallbacks(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using Discord; | |
public class DiscordController : MonoBehaviour { | |
public Discord.Discord discord; | |
// Use this for initialization | |
void Start () { | |
discord = new Discord.Discord(461618159171141643, (System.UInt64)Discord.CreateFlags.Default); | |
var lobbyManager = discord.GetLobbyManager(); | |
lobbyManager.OnMemberUpdate += (lobbyId, userId) => | |
{ | |
Debug.Log("user " + userId + "got updated"); | |
}; | |
var txn = lobbyManager.GetLobbyCreateTransaction(); | |
txn.SetCapacity(2); | |
lobbyManager.CreateLobby(txn, (Discord.Result res, ref Discord.Lobby lobby) => | |
{ | |
if (res == Discord.Result.Ok) | |
{ | |
Debug.Log("Owner is: " + lobby.OwnerId); | |
Debug.Log("Connect with: " + lobbyManager.GetLobbyActivitySecret(lobby.Id)); | |
} | |
}); | |
} | |
// Update is called once per frame | |
void Update () { | |
discord.RunCallbacks(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment