2017-08-02 19:31:35 +01:00
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
|
|
public class DiscordRpc
|
|
|
|
|
{
|
2017-09-28 16:15:15 +01:00
|
|
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
2017-08-02 19:31:35 +01:00
|
|
|
|
public delegate void ReadyCallback();
|
|
|
|
|
|
2017-09-28 16:15:15 +01:00
|
|
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
2017-08-02 19:31:35 +01:00
|
|
|
|
public delegate void DisconnectedCallback(int errorCode, string message);
|
|
|
|
|
|
2017-09-28 16:15:15 +01:00
|
|
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
2017-08-02 19:31:35 +01:00
|
|
|
|
public delegate void ErrorCallback(int errorCode, string message);
|
|
|
|
|
|
2017-09-28 16:15:15 +01:00
|
|
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
2017-08-02 19:31:35 +01:00
|
|
|
|
public delegate void JoinCallback(string secret);
|
|
|
|
|
|
2017-09-28 16:15:15 +01:00
|
|
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
2017-08-02 19:31:35 +01:00
|
|
|
|
public delegate void SpectateCallback(string secret);
|
|
|
|
|
|
2017-10-14 11:21:35 +01:00
|
|
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
2017-11-30 20:23:40 +00:00
|
|
|
|
public delegate void RequestCallback(ref JoinRequest request);
|
2017-10-14 11:12:03 +01:00
|
|
|
|
|
2017-10-14 11:21:35 +01:00
|
|
|
|
public struct EventHandlers
|
2017-08-02 19:31:35 +01:00
|
|
|
|
{
|
|
|
|
|
public ReadyCallback readyCallback;
|
|
|
|
|
public DisconnectedCallback disconnectedCallback;
|
|
|
|
|
public ErrorCallback errorCallback;
|
|
|
|
|
public JoinCallback joinCallback;
|
|
|
|
|
public SpectateCallback spectateCallback;
|
2017-10-14 11:21:35 +01:00
|
|
|
|
public RequestCallback requestCallback;
|
|
|
|
|
}
|
2017-08-02 19:31:35 +01:00
|
|
|
|
|
|
|
|
|
[System.Serializable]
|
|
|
|
|
public struct RichPresence
|
|
|
|
|
{
|
|
|
|
|
public string state; /* max 128 bytes */
|
|
|
|
|
public string details; /* max 128 bytes */
|
|
|
|
|
public long startTimestamp;
|
|
|
|
|
public long endTimestamp;
|
|
|
|
|
public string largeImageKey; /* max 32 bytes */
|
|
|
|
|
public string largeImageText; /* max 128 bytes */
|
|
|
|
|
public string smallImageKey; /* max 32 bytes */
|
|
|
|
|
public string smallImageText; /* max 128 bytes */
|
|
|
|
|
public string partyId; /* max 128 bytes */
|
|
|
|
|
public int partySize;
|
|
|
|
|
public int partyMax;
|
|
|
|
|
public string matchSecret; /* max 128 bytes */
|
|
|
|
|
public string joinSecret; /* max 128 bytes */
|
|
|
|
|
public string spectateSecret; /* max 128 bytes */
|
|
|
|
|
public bool instance;
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-02 18:59:45 +00:00
|
|
|
|
[System.Serializable]
|
2017-10-14 11:21:35 +01:00
|
|
|
|
public struct JoinRequest
|
|
|
|
|
{
|
|
|
|
|
public string userId;
|
|
|
|
|
public string username;
|
2017-11-30 19:24:12 +00:00
|
|
|
|
public string discriminator;
|
2017-10-17 21:33:12 +01:00
|
|
|
|
public string avatar;
|
2017-10-14 11:21:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum Reply
|
|
|
|
|
{
|
|
|
|
|
No = 0,
|
|
|
|
|
Yes = 1,
|
|
|
|
|
Ignore = 2
|
|
|
|
|
}
|
2017-10-14 11:12:03 +01:00
|
|
|
|
|
2017-09-28 16:15:15 +01:00
|
|
|
|
[DllImport("discord-rpc", EntryPoint = "Discord_Initialize", CallingConvention = CallingConvention.Cdecl)]
|
2017-08-30 23:17:47 +01:00
|
|
|
|
public static extern void Initialize(string applicationId, ref EventHandlers handlers, bool autoRegister, string optionalSteamId);
|
2017-08-02 19:31:35 +01:00
|
|
|
|
|
2017-09-28 16:15:15 +01:00
|
|
|
|
[DllImport("discord-rpc", EntryPoint = "Discord_Shutdown", CallingConvention = CallingConvention.Cdecl)]
|
2017-08-02 19:31:35 +01:00
|
|
|
|
public static extern void Shutdown();
|
|
|
|
|
|
2017-09-28 16:15:15 +01:00
|
|
|
|
[DllImport("discord-rpc", EntryPoint = "Discord_RunCallbacks", CallingConvention = CallingConvention.Cdecl)]
|
2017-08-02 19:31:35 +01:00
|
|
|
|
public static extern void RunCallbacks();
|
|
|
|
|
|
2017-09-28 16:15:15 +01:00
|
|
|
|
[DllImport("discord-rpc", EntryPoint = "Discord_UpdatePresence", CallingConvention = CallingConvention.Cdecl)]
|
2017-08-02 19:31:35 +01:00
|
|
|
|
public static extern void UpdatePresence(ref RichPresence presence);
|
2017-10-14 11:12:03 +01:00
|
|
|
|
|
2017-10-14 11:21:35 +01:00
|
|
|
|
[DllImport("discord-rpc", EntryPoint = "Discord_Respond", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
public static extern void Respond(string userId, Reply reply);
|
2017-08-02 19:31:35 +01:00
|
|
|
|
}
|
|
|
|
|
|