diff --git a/examples/unrealstatus/Content/ShowTheUILevel.umap b/examples/unrealstatus/Content/ShowTheUILevel.umap index 1b100e4..7b68148 100644 Binary files a/examples/unrealstatus/Content/ShowTheUILevel.umap and b/examples/unrealstatus/Content/ShowTheUILevel.umap differ diff --git a/examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/Private/DiscordRpcBlueprint.cpp b/examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/Private/DiscordRpcBlueprint.cpp index ec06144..2f509ae 100644 --- a/examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/Private/DiscordRpcBlueprint.cpp +++ b/examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/Private/DiscordRpcBlueprint.cpp @@ -7,6 +7,7 @@ DEFINE_LOG_CATEGORY(Discord) static UDiscordRpc* self = nullptr; + static void ReadyHandler() { UE_LOG(Discord, Log, TEXT("Discord connected")); @@ -53,6 +54,19 @@ static void SpectateGameHandler(const char* spectateSecret) } } +static void JoinRequestHandler(const DiscordJoinRequest* request) +{ + FDiscordJoinRequestData jr; + jr.userId = ANSI_TO_TCHAR(request->userId); + jr.username = ANSI_TO_TCHAR(request->username); + jr.discriminator = ANSI_TO_TCHAR(request->discriminator); + jr.avatar = ANSI_TO_TCHAR(request->avatar); + UE_LOG(Discord, Log, TEXT("Discord join request from %s#%s"), *jr.username, *jr.discriminator); + if (self) { + self->OnJoinRequest.Broadcast(jr); + } +} + void UDiscordRpc::Initialize(const FString& applicationId, bool autoRegister, const FString& optionalSteamId) @@ -69,6 +83,9 @@ void UDiscordRpc::Initialize(const FString& applicationId, if (OnSpectate.IsBound()) { handlers.spectateGame = SpectateGameHandler; } + if (OnJoinRequest.IsBound()) { + handlers.joinRequest = JoinRequestHandler; + } auto appId = StringCast(*applicationId); auto steamId = StringCast(*optionalSteamId); Discord_Initialize( diff --git a/examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/Public/DiscordRpcBlueprint.h b/examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/Public/DiscordRpcBlueprint.h index 69f2b64..daf1ca5 100644 --- a/examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/Public/DiscordRpcBlueprint.h +++ b/examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/Public/DiscordRpcBlueprint.h @@ -9,6 +9,24 @@ // unreal's header tool hates clang-format // clang-format off +/** +* Ask to join callback data +*/ +USTRUCT(BlueprintType) +struct FDiscordJoinRequestData { + GENERATED_USTRUCT_BODY() + + UPROPERTY(BlueprintReadOnly) + FString userId; + UPROPERTY(BlueprintReadOnly) + FString username; + UPROPERTY(BlueprintReadOnly) + FString discriminator; + UPROPERTY(BlueprintReadOnly) + FString avatar; +}; + + DECLARE_LOG_CATEGORY_EXTERN(Discord, Log, All); DECLARE_DYNAMIC_MULTICAST_DELEGATE(FDiscordConnected); @@ -16,6 +34,7 @@ DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FDiscordDisconnected, int, errorCod DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FDiscordErrored, int, errorCode, const FString&, errorMessage); DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FDiscordJoin, const FString&, joinSecret); DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FDiscordSpectate, const FString&, spectateSecret); +DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FDiscordJoinRequest, const FDiscordJoinRequestData&, joinRequest); // clang-format on @@ -119,6 +138,12 @@ public: Category = "Discord") FDiscordSpectate OnSpectate; + UPROPERTY(BlueprintAssignable, + meta = (DisplayName = "When Discord another user sends a join request", + Keywords = "Discord rpc"), + Category = "Discord") + FDiscordJoinRequest OnJoinRequest; + UPROPERTY(BlueprintReadWrite, meta = (DisplayName = "Rich presence info", Keywords = "Discord rpc"), Category = "Discord") diff --git a/examples/unrealstatus/unrealstatus.uproject b/examples/unrealstatus/unrealstatus.uproject index 34bf4ac..8a4a40b 100644 --- a/examples/unrealstatus/unrealstatus.uproject +++ b/examples/unrealstatus/unrealstatus.uproject @@ -1,6 +1,6 @@ { "FileVersion": 3, - "EngineAssociation": "4.16", + "EngineAssociation": "4.18", "Category": "", "Description": "", "Modules": [