mirror of
https://github.com/yuzu-emu/discord-rpc.git
synced 2024-12-23 00:15:39 +00:00
Added request to join functionality
This commit is contained in:
parent
86ca320cb9
commit
e4b3ef63b7
|
@ -53,6 +53,12 @@ public class DiscordController : MonoBehaviour {
|
|||
Debug.Log(string.Format("Discord: spectate ({0})", secret));
|
||||
}
|
||||
|
||||
public void RequestCallback(DiscordRpc.JoinRequest request)
|
||||
{
|
||||
++callbackCalls;
|
||||
Debug.Log(string.Format("Discord: join request {0}: {1}", request.username, request.userId));
|
||||
}
|
||||
|
||||
void Start () {
|
||||
}
|
||||
|
||||
|
@ -71,6 +77,7 @@ public class DiscordController : MonoBehaviour {
|
|||
handlers.errorCallback += ErrorCallback;
|
||||
handlers.joinCallback += JoinCallback;
|
||||
handlers.spectateCallback += SpectateCallback;
|
||||
handlers.requestCallback += RequestCallback;
|
||||
DiscordRpc.Initialize(applicationId, ref handlers, true, optionalSteamId);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,9 @@ public class DiscordRpc
|
|||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void SpectateCallback(string secret);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void RequestCallback(JoinRequest request);
|
||||
|
||||
public struct EventHandlers
|
||||
{
|
||||
public ReadyCallback readyCallback;
|
||||
|
@ -24,6 +27,7 @@ public class DiscordRpc
|
|||
public ErrorCallback errorCallback;
|
||||
public JoinCallback joinCallback;
|
||||
public SpectateCallback spectateCallback;
|
||||
public RequestCallback requestCallback;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
|
@ -46,6 +50,24 @@ public class DiscordRpc
|
|||
public bool instance;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
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 avatarUrl;
|
||||
}
|
||||
|
||||
public enum Reply
|
||||
{
|
||||
No = 0,
|
||||
Yes = 1,
|
||||
Ignore = 2
|
||||
}
|
||||
|
||||
[DllImport("discord-rpc", EntryPoint = "Discord_Initialize", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Initialize(string applicationId, ref EventHandlers handlers, bool autoRegister, string optionalSteamId);
|
||||
|
||||
|
@ -57,5 +79,8 @@ public class DiscordRpc
|
|||
|
||||
[DllImport("discord-rpc", EntryPoint = "Discord_UpdatePresence", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void UpdatePresence(ref RichPresence presence);
|
||||
|
||||
[DllImport("discord-rpc", EntryPoint = "Discord_Respond", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Respond(string userId, Reply reply);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue