diff --git a/examples/button-clicker/Assets/DiscordRpc.cs b/examples/button-clicker/Assets/DiscordRpc.cs index 206504e..fde94d9 100644 --- a/examples/button-clicker/Assets/DiscordRpc.cs +++ b/examples/button-clicker/Assets/DiscordRpc.cs @@ -50,14 +50,11 @@ public class DiscordRpc public bool instance; } - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + [System.Serializable] public struct JoinRequest { - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 24)] public string userId; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 48)] public string username; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] public string avatar; } diff --git a/examples/button-clicker/Assets/Resources/discord-rpc.dll b/examples/button-clicker/Assets/Resources/discord-rpc.dll index 5daec3d..67ef709 100644 Binary files a/examples/button-clicker/Assets/Resources/discord-rpc.dll and b/examples/button-clicker/Assets/Resources/discord-rpc.dll differ diff --git a/include/discord-rpc.h b/include/discord-rpc.h index bff30f5..a81673e 100644 --- a/include/discord-rpc.h +++ b/include/discord-rpc.h @@ -42,9 +42,9 @@ typedef struct DiscordRichPresence { } DiscordRichPresence; typedef struct DiscordJoinRequest { - char userId[24]; - char username[48]; - char avatar[128]; + const char* userId; + const char* username; + const char* avatar; } DiscordJoinRequest; typedef struct DiscordEventHandlers { diff --git a/src/discord-rpc.cpp b/src/discord-rpc.cpp index 1b846f0..1d5e6d0 100644 --- a/src/discord-rpc.cpp +++ b/src/discord-rpc.cpp @@ -32,6 +32,12 @@ struct QueuedMessage { } }; +struct JoinRequest { + char userId[24]; + char username[48]; + char avatar[128]; +}; + static RpcConnection* Connection{nullptr}; static DiscordEventHandlers Handlers{}; static std::atomic_bool WasJustConnected{false}; @@ -48,7 +54,7 @@ static char LastDisconnectErrorMessage[256]; static std::mutex PresenceMutex; static QueuedMessage QueuedPresence{}; static MsgQueue SendQueue; -static MsgQueue JoinAskQueue; +static MsgQueue JoinAskQueue; // We want to auto connect, and retry on failure, but not as fast as possible. This does expoential // backoff from 0.5 seconds to 1 minute @@ -353,7 +359,8 @@ extern "C" DISCORD_EXPORT void Discord_RunCallbacks() while (JoinAskQueue.HavePendingSends()) { auto req = JoinAskQueue.GetNextSendMessage(); if (Handlers.joinRequest) { - Handlers.joinRequest(req); + DiscordJoinRequest djr{req->userId, req->username, req->avatar}; + Handlers.joinRequest(&djr); } JoinAskQueue.CommitSend(); }