示例#1
0
    /// <summary>
    /// Update an attribute that is attached to the lobby.
    /// </summary>
    /// <param name="attribute">The new data to apply.</param>
    private void UpdateAttribute(AttributeData attribute)
    {
        LobbyModification modHandle = new LobbyModification();

        EOSSDKComponent.GetLobbyInterface().UpdateLobbyModification(new UpdateLobbyModificationOptions {
            LobbyId = currentLobbyId, LocalUserId = EOSSDKComponent.LocalUserProductId
        }, out modHandle);

        modHandle.AddAttribute(new LobbyModificationAddAttributeOptions {
            Attribute = attribute, Visibility = LobbyAttributeVisibility.Public
        });

        EOSSDKComponent.GetLobbyInterface().UpdateLobby(new UpdateLobbyOptions {
            LobbyModificationHandle = modHandle
        }, null, (UpdateLobbyCallbackInfo callback) => {
            if (callback.ResultCode != Result.Success)
            {
                AttributeUpdateFailed?.Invoke(attribute.Key, $"There was an error while updating attribute \"{ attribute.Key }\". Error: " + callback.ResultCode);
                return;
            }

            AttributeUpdateSucceeded?.Invoke(attribute.Key);
        });
    }
示例#2
0
    /// <summary>
    /// Remove an attribute attached to the lobby.
    /// </summary>
    /// <param name="key">The key of the attribute that will be removed.</param>
    public virtual void RemoveAttribute(string key)
    {
        LobbyModification modHandle = new LobbyModification();

        EOSSDKComponent.GetLobbyInterface().UpdateLobbyModification(new UpdateLobbyModificationOptions {
            LobbyId = currentLobbyId, LocalUserId = EOSSDKComponent.LocalUserProductId
        }, out modHandle);

        modHandle.RemoveAttribute(new LobbyModificationRemoveAttributeOptions {
            Key = key
        });

        EOSSDKComponent.GetLobbyInterface().UpdateLobby(new UpdateLobbyOptions {
            LobbyModificationHandle = modHandle
        }, null, (UpdateLobbyCallbackInfo callback) => {
            if (callback.ResultCode != Result.Success)
            {
                AttributeUpdateFailed?.Invoke(key, $"There was an error while removing attribute \"{ key }\". Error: " + callback.ResultCode);
                return;
            }

            AttributeUpdateSucceeded?.Invoke(key);
        });
    }