mirror of
https://github.com/yuzu-emu/discord-rpc.git
synced 2024-12-23 00:35:31 +00:00
Unity ajt fix
This commit is contained in:
parent
aa79c70bf9
commit
3bdb88d918
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
|
@ -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 {
|
||||
|
|
|
@ -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<QueuedMessage, MessageQueueSize> SendQueue;
|
||||
static MsgQueue<DiscordJoinRequest, JoinQueueSize> JoinAskQueue;
|
||||
static MsgQueue<JoinRequest, JoinQueueSize> 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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue