|
19 | 19 | import com.sun.jna.Library; |
20 | 20 | import com.sun.jna.Native; |
21 | 21 |
|
| 22 | +/** |
| 23 | + * Core library binding for the official <a href="https://github.com/discordapp/discord-rpc" target="_blank">Discord RPC SDK</a>. |
| 24 | + * <br>Use {@link #INSTANCE} to access this library. |
| 25 | + * |
| 26 | + * <h1>Supported Architectures</h1> |
| 27 | + * <ul> |
| 28 | + * <li>Windows x86-64</li> |
| 29 | + * <li>Linux x86-64</li> |
| 30 | + * <li>Darwin</li> |
| 31 | + * </ul> |
| 32 | + */ |
22 | 33 | public interface DiscordRPC extends Library |
23 | 34 | { |
| 35 | + /** |
| 36 | + * Library instance. |
| 37 | + */ |
24 | 38 | DiscordRPC INSTANCE = Native.loadLibrary("discord-rpc", DiscordRPC.class); |
25 | 39 |
|
| 40 | + /** |
| 41 | + * Used to decline a request via {@link #Discord_Respond(String, int)} |
| 42 | + * @see #DISCORD_REPLY_YES |
| 43 | + */ |
26 | 44 | int DISCORD_REPLY_NO = 0; |
| 45 | + /** |
| 46 | + * Used to accept a request via {@link #Discord_Respond(String, int)} |
| 47 | + * @see #DISCORD_REPLY_NO |
| 48 | + */ |
27 | 49 | int DISCORD_REPLY_YES = 1; |
| 50 | + /** |
| 51 | + * Currently unsused response, treated like NO. |
| 52 | + * Used with {@link #Discord_Respond(String, int)} |
| 53 | + * @see #DISCORD_REPLY_NO |
| 54 | + */ |
28 | 55 | int DISCORD_REPLY_IGNORE = 2; |
29 | 56 |
|
| 57 | + /** |
| 58 | + * Initializes the library, supply with application details and event handlers. |
| 59 | + * Handlers are only called when the {@link #Discord_RunCallbacks()} method is invoked! |
| 60 | + * <br><b>Before closing the application it is recommended to call {@link #Discord_Shutdown()}</b> |
| 61 | + * |
| 62 | + * @param applicationId |
| 63 | + * The ID for this RPC application, |
| 64 | + * retrieved from the <a href="https://discordappc.com/developers/applications/me" target="_blank">developer dashboard</a> |
| 65 | + * @param handlers |
| 66 | + * Nullable instance of {@link club.minnced.discord.rpc.DiscordEventHandlers} |
| 67 | + * @param autoRegister |
| 68 | + * {@code true} to automatically call {@link #Discord_RegisterSteamGame(String, String)} or {@link #Discord_Register(String, String)} |
| 69 | + * @param steamId |
| 70 | + * Possible steam ID of the running game |
| 71 | + */ |
30 | 72 | void Discord_Initialize(String applicationId, |
31 | 73 | DiscordEventHandlers handlers, |
32 | 74 | boolean autoRegister, |
33 | 75 | String steamId); |
| 76 | + |
| 77 | + /** |
| 78 | + * Shuts the RPC connection down. |
| 79 | + * If not currently connected, this does nothing. |
| 80 | + */ |
34 | 81 | void Discord_Shutdown(); |
35 | 82 |
|
| 83 | + /** |
| 84 | + * Executes the registered handlers for currently queued events. |
| 85 | + * <br>If this is not called the handlers will not receive any events! |
| 86 | + * |
| 87 | + * <p>It is recommended to call this in a <u>2 second interval</u> |
| 88 | + */ |
36 | 89 | void Discord_RunCallbacks(); |
| 90 | + |
| 91 | + /** |
| 92 | + * Polls events from the RPC pipe and pushes the currently queued presence. |
| 93 | + * <br>This will be performed automatically if the attached binary |
| 94 | + * has an enabled IO thread (default) |
| 95 | + * |
| 96 | + * <p><b>If the IO-Thread has been enabled this will not be supported!</b> |
| 97 | + */ |
37 | 98 | void Discord_UpdateConnection(); |
38 | 99 |
|
| 100 | + /** |
| 101 | + * Updates the currently set presence of the logged in user. |
| 102 | + * <br>Note that the client only updates its presence every <b>15 seconds</b> |
| 103 | + * and queues all additional presence updates. |
| 104 | + * |
| 105 | + * @param struct |
| 106 | + * The new presence to use, or null to reset |
| 107 | + * |
| 108 | + * @see club.minnced.discord.rpc.DiscordRichPresence |
| 109 | + */ |
39 | 110 | void Discord_UpdatePresence(DiscordRichPresence struct); |
| 111 | + |
| 112 | + /** |
| 113 | + * Responds to the given user with the specified reply type. |
| 114 | + * |
| 115 | + * <h1>Possible Replies</h1> |
| 116 | + * <ul> |
| 117 | + * <li>{@link #DISCORD_REPLY_NO}</li> |
| 118 | + * <li>{@link #DISCORD_REPLY_YES}</li> |
| 119 | + * <li>{@link #DISCORD_REPLY_IGNORE}</li> |
| 120 | + * </ul> |
| 121 | + * |
| 122 | + * @param userid |
| 123 | + * The id of the user to respond to |
| 124 | + * @param reply |
| 125 | + * The reply type |
| 126 | + * |
| 127 | + * @see club.minnced.discord.rpc.DiscordJoinRequest#userId DiscordJoinRequest.userId |
| 128 | + */ |
40 | 129 | void Discord_Respond(String userid, int reply); |
| 130 | + |
| 131 | + /** |
| 132 | + * Registers the given application so it can be run by the discord client. {@code discord-<appid>://} |
| 133 | + * |
| 134 | + * @param applicationId |
| 135 | + * The ID of the application to register |
| 136 | + * @param command |
| 137 | + * The command for the application startup, or {@code null} to use the |
| 138 | + * current executable's path |
| 139 | + */ |
| 140 | + void Discord_Register(String applicationId, String command); |
| 141 | + |
| 142 | + /** |
| 143 | + * Similar to {@link #Discord_Register(String, String)} but uses the steam |
| 144 | + * game's installation path. |
| 145 | + * |
| 146 | + * @param applicationId |
| 147 | + * The ID of the application to register |
| 148 | + * @param steamId |
| 149 | + * The steam ID for the game |
| 150 | + */ |
| 151 | + void Discord_RegisterSteamGame(String applicationId, String steamId); |
41 | 152 | } |
0 commit comments