Discord SDK:lobbyManager.ConnectLobby()返回NotFound

时间:2019-04-25 22:51:59

标签: discord

加入大厅:

public void JoinLobby(String lobbyIdSecret)
    {
        String[] parsedItems = lobbyIdSecret.Split(':');
        lobbyId = Int64.Parse(parsedItems[0]);
        lobbySecret = parsedItems[1];

        lobbyManager.ConnectLobby(lobbyId, lobbySecret, (Discord.Result result, ref Discord.Lobby lobby) =>
        {
            Debug.Log(String.Format("Result: {0}", result));
        });
    }

我已经创建了一个大厅,现在我正试图将另一个用户连接到它。但是,结果是我得到了NotFound。我知道ID和机密是正确的。有什么想法可能有问题吗?

创建大厅:

public void CreateLobby(LobbyCreatedCB cb)
    {
        // Create the transaction
        var txn = lobbyManager.GetLobbyCreateTransaction();

        // Set lobby information
        txn.SetCapacity(6);
        txn.SetType(Discord.LobbyType.Public);
        txn.SetMetadata("a", "123");

        // Create it!
        lobbyManager.CreateLobby(txn, (Discord.Result result, ref Discord.Lobby lobby) =>
        {
            lobbyId = lobby.Id;
            lobbySecret = lobby.Secret;

            Debug.Log(String.Format("lobby {0} created with secret {1}", lobbyId, lobby.Secret));
            Debug.Log(String.Format("lobby has {0} user connected", lobbyManager.MemberCount(lobbyId))); 

            // We want to update the capacity of the lobby
            // So we get a new transaction for the lobby
            var newTxn = lobbyManager.GetLobbyUpdateTransaction(lobby.Id);
            newTxn.SetCapacity(5);

            lobbyManager.UpdateLobby(lobby.Id, newTxn, (updatedResult) =>
            {
                Debug.Log(String.Format("lobby {0} updated", updatedResult));
            });

            UpdateActivity(discord, lobby);

            cb(String.Format("{0}:{1}", lobbyId, lobbySecret));
        });

    }

编辑:将加入大厅代码段更改为我正在使用的确切代码。添加了创建大厅功能。

1 个答案:

答案 0 :(得分:0)

不确定是否只是向后编写参数类型,但是在SDK中,idInt64,而secretstring。如果您的编译器在运行代码之前还没有大喊大叫就停止,则可能是SDK不确定如何处理ID的字符串并返回NotFound。您还可以发布用于创建大厅的代码段吗?