Comments (11)
I don't see how this could be caused by either the discord-rpc SDK or this binding. I believe this is rather your application than this library or binding target.
from java-discord-rpc.
The issue is, I'm currently using this in Minecraft and I'm not sure how to prevent this issue. What happens is when a user leaves a server and then quits the game quickly, it sends the update on the menu load but that arrives AFTER the shutdown. If you could point me in the right direction, that'd be awesome.
from java-discord-rpc.
This kind of thing happens whenever you don't properly shut RPC down. If you exit your program before calling it (or before it finishes executing, since it seems like it takes a few seconds), you get the bug as described.
IMO I think the fact that the client can't self-update if the app is closed makes me think it's an issue with the SDK, as I don't really see a workaround to the user closing it too quickly.
from java-discord-rpc.
I'm having a bit of trouble understanding exactly the steps you're describing, but it sounds like what's happening is:
- Push
Update_Presence()
call - Call
Shutdown()
- Status disappears
- Status reappears
As mentioned via email, Discord determines status by the process ID of the program sending it presence updates. If you have Minecraft running and sending presence updates, and then call Shutdown()
but don't close Minecraft, we still see the process id and think "Hey, they're still playing, keep showing whatever they sent us last".
Am I correct that the above steps are what you are describing?
from java-discord-rpc.
I believe the steps are correct but what you're describing doesn't sound correct, um..
Here's the steps that happens:
- User leaves a Minecraft server and returns to title screen, causing presence to update to "Main Menu"
- Sends an
Update_Presence()
- Sends an
- User quits the game before the
Update_Presence()
has finished sending- Sends a
Shutdown()
beforeUpdate_Presence()
has finished
- Sends a
- The shutdown arrives before the
Update_Presence()
, causing the game to disappear (like you quit).- The
Shutdown()
arrives before theUpdate_Presence()
- The
- The
Update_Presence()
arrives to Discord, returning the game to your profile.- The
Update_Presence()
arrives
- The
In the end, Minecraft is actually closed, while the presence is still showing.
from java-discord-rpc.
So I did a bit of testing and found out that although the Minecraft modding library (Minecraft Forge) doesn't actually have an "on game shutdown" event, you can still achieve this by using Runtime#addShutdownHook. An example with the RPC library being instantiated as lib
can be done as Runtime.getRuntime().addShutdownHook(new Thread(lib::Discord_Shutdown));
.
from java-discord-rpc.
@kkirigaya That's exactly what I have and that is what causes the issue.
from java-discord-rpc.
Okay so for everyone participating in this thread, here's a video explaining exactly the issue I'm having.
And here's my presence file & the events that cause these to happen.
package com.firecontrol.minecraftdrp.RPC;
import com.firecontrol.minecraftdrp.MinecraftDRP;
import com.firecontrol.minecraftdrp.Reference;
import com.firecontrol.minecraftdrp.Handlers.RPCEventHandler;
import club.minnced.discord.rpc.DiscordEventHandlers;
import club.minnced.discord.rpc.DiscordRPC;
import club.minnced.discord.rpc.DiscordRichPresence;
public class RPCClient {
private Thread callback;
public void initialize() {
DiscordEventHandlers handlers = new DiscordEventHandlers();
handlers = RPCEventHandler.setupEvents(handlers);
DiscordRPC.INSTANCE.Discord_Initialize(Reference.CLIENT_ID, handlers, true, null);
if (callback == null) {
callback = new Thread(() -> {
while (!Thread.currentThread().isInterrupted()) {
DiscordRPC.INSTANCE.Discord_RunCallbacks();
try {
Thread.sleep(2000);
} catch (InterruptedException ignored) {
}
}
}, "RPC-Callback-Handler");
callback.start();
}
MinecraftDRP.logger.info("Created new client.");
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
DiscordRPC.INSTANCE.Discord_Shutdown();
}
});
}
public void setPresence(DiscordRichPresence newPresence) {
DiscordRPC.INSTANCE.Discord_UpdatePresence(newPresence);
}
}
Here's the event.
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void disconnectFromServerEvent(ClientDisconnectionFromServerEvent event) {
Reference.serverPresence = null;
DiscordRichPresence presence = new DiscordRichPresence();
presence.state = "Main Menu";
presence.largeImageKey = "crafting_large";
presence.largeImageText = Display.getTitle();
MinecraftDRP.DRPC.setPresence(presence);
}
from java-discord-rpc.
Okay so @kkirigaya and I have decided the simplest way to fix this would just be adding a "queue"-like system into the module that prevents multiple calls being sent at once.
from java-discord-rpc.
This looks very similar to discord/discord-rpc#61 and they're saying it's fixed. Is this similar or no?
from java-discord-rpc.
Closed via discord/discord-rpc#85
from java-discord-rpc.
Related Issues (20)
- Module not found HOT 6
- [Request/Help] Function to check if an Image Exists? HOT 3
- [Error/Bug] MacOS Error Loading dll (Code Signature Invalid) HOT 5
- Problem HOT 3
- Handlers not being triggered HOT 7
- Unable to load library 'discord-rpc': The specified module could not be found. HOT 15
- Imposible to use it in a minecraft mod HOT 6
- Error in LSRegisterURL: -10811 HOT 1
- This is not issue, but question HOT 1
- How to reset StartTimestamp and EndTimestamp presences? HOT 1
- jcenter returning 502 HOT 1
- UnsatisfiedLinkError on release jar HOT 7
- How to utilize Discord_Initialize() to connect to second local instance of Discord HOT 4
- Deprecation of the official Discord SDK for RPC HOT 1
- Unable to load library 'discord-rpc' Minecraft 1.8.8 MCP Error HOT 2
- This is less of an issue and more of something i want to know HOT 1
- About secret HOT 2
- Error in LSRegisterURL: -10811 HOT 1
- java.lang.UnsatisfiedLinkError: Unable to load library 'discord-rpc' HOT 1
- Suggestion HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from java-discord-rpc.