Advertisement
raxerz

Untitled

Jan 26th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. using System.Runtime.InteropServices;
  2.  
  3. namespace DiscordRpcClient
  4. {
  5. // https://github.com/discordapp/discord-rpc/blob/master/examples/button-clicker/Assets/DiscordRpc.cs
  6. public class DiscordRpc
  7. {
  8. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  9. public delegate void ReadyCallback();
  10.  
  11. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  12. public delegate void DisconnectedCallback(int errorCode, string message);
  13.  
  14. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  15. public delegate void ErrorCallback(int errorCode, string message);
  16.  
  17. public struct EventHandlers
  18. {
  19. public ReadyCallback readyCallback;
  20. public DisconnectedCallback disconnectedCallback;
  21. public ErrorCallback errorCallback;
  22. }
  23.  
  24. // Values explanation and example: https://discordapp.com/developers/docs/rich-presence/how-to#updating-presence-update-presence-payload-fields
  25. [System.Serializable]
  26. public struct RichPresence
  27. {
  28. public string state; /* max 128 bytes */
  29. public string details; /* max 128 bytes */
  30. public long startTimestamp;
  31. public long endTimestamp;
  32. public string largeImageKey; /* max 32 bytes */
  33. public string largeImageText; /* max 128 bytes */
  34. public string smallImageKey; /* max 32 bytes */
  35. public string smallImageText; /* max 128 bytes */
  36. public string partyId; /* max 128 bytes */
  37. public int partySize;
  38. public int partyMax;
  39. public string matchSecret; /* max 128 bytes */
  40. public string joinSecret; /* max 128 bytes */
  41. public string spectateSecret; /* max 128 bytes */
  42. public bool instance;
  43. }
  44.  
  45. [DllImport("discord-rpc-w32.dll", EntryPoint = "Discord_Initialize", CallingConvention = CallingConvention.Cdecl)]
  46. public static extern void Initialize(string applicationId, ref EventHandlers handlers, bool autoRegister, string optionalSteamId);
  47.  
  48. [DllImport("discord-rpc-w32.dll", EntryPoint = "Discord_UpdatePresence", CallingConvention = CallingConvention.Cdecl)]
  49. public static extern void UpdatePresence(ref RichPresence presence);
  50.  
  51. [DllImport("discord-rpc-w32.dll", EntryPoint = "Discord_RunCallbacks", CallingConvention = CallingConvention.Cdecl)]
  52. public static extern void RunCallbacks();
  53.  
  54. [DllImport("discord-rpc-w32.dll", EntryPoint = "Discord_Shutdown", CallingConvention = CallingConvention.Cdecl)]
  55. public static extern void Shutdown();
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement