Unity ajt fix
This commit is contained in:
parent
aa79c70bf9
commit
3bdb88d918
4 changed files with 13 additions and 9 deletions
|
@ -50,14 +50,11 @@ public class DiscordRpc
|
||||||
public bool instance;
|
public bool instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
[System.Serializable]
|
||||||
public struct JoinRequest
|
public struct JoinRequest
|
||||||
{
|
{
|
||||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 24)]
|
|
||||||
public string userId;
|
public string userId;
|
||||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 48)]
|
|
||||||
public string username;
|
public string username;
|
||||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
|
|
||||||
public string avatar;
|
public string avatar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -42,9 +42,9 @@ typedef struct DiscordRichPresence {
|
||||||
} DiscordRichPresence;
|
} DiscordRichPresence;
|
||||||
|
|
||||||
typedef struct DiscordJoinRequest {
|
typedef struct DiscordJoinRequest {
|
||||||
char userId[24];
|
const char* userId;
|
||||||
char username[48];
|
const char* username;
|
||||||
char avatar[128];
|
const char* avatar;
|
||||||
} DiscordJoinRequest;
|
} DiscordJoinRequest;
|
||||||
|
|
||||||
typedef struct DiscordEventHandlers {
|
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 RpcConnection* Connection{nullptr};
|
||||||
static DiscordEventHandlers Handlers{};
|
static DiscordEventHandlers Handlers{};
|
||||||
static std::atomic_bool WasJustConnected{false};
|
static std::atomic_bool WasJustConnected{false};
|
||||||
|
@ -48,7 +54,7 @@ static char LastDisconnectErrorMessage[256];
|
||||||
static std::mutex PresenceMutex;
|
static std::mutex PresenceMutex;
|
||||||
static QueuedMessage QueuedPresence{};
|
static QueuedMessage QueuedPresence{};
|
||||||
static MsgQueue<QueuedMessage, MessageQueueSize> SendQueue;
|
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
|
// 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
|
// backoff from 0.5 seconds to 1 minute
|
||||||
|
@ -353,7 +359,8 @@ extern "C" DISCORD_EXPORT void Discord_RunCallbacks()
|
||||||
while (JoinAskQueue.HavePendingSends()) {
|
while (JoinAskQueue.HavePendingSends()) {
|
||||||
auto req = JoinAskQueue.GetNextSendMessage();
|
auto req = JoinAskQueue.GetNextSendMessage();
|
||||||
if (Handlers.joinRequest) {
|
if (Handlers.joinRequest) {
|
||||||
Handlers.joinRequest(req);
|
DiscordJoinRequest djr{req->userId, req->username, req->avatar};
|
||||||
|
Handlers.joinRequest(&djr);
|
||||||
}
|
}
|
||||||
JoinAskQueue.CommitSend();
|
JoinAskQueue.CommitSend();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue