Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweaks from the last few years #24

Open
wants to merge 62 commits into
base: master
Choose a base branch
from
Open

Conversation

CDAGaming
Copy link

@CDAGaming CDAGaming commented Sep 25, 2022

I run a minecraft mod called CraftPresence that, until recently, was using a jar-in-jar'd fork of this implementation of Discord's IPC system.

There will probably be quite a few questions, of which I'd be glad to answer, though I still plan to keep maintaining this fork so long as mod my mod keeps growing. Thank you again for making this amazing tool, as it's been fun to keep it going for awhile +1

Here is a list of changes that have come over time, in a greatly summarized form:

  • Added autoRegister support (WinRegistry class added for Windows, tested up to Java 17/18)
  • Updated JUnixSocket to 2.4.0, technically superseeding Add support for M1 Macs and add an IPCTest class #20
    • Technically, this can go higher, but steps have been taken to retain support for Java 7, so we cannot go higher at least in this scope.
  • Use GSON instead of org.json
  • Same reason as prior note, game environments can more easily implement GSON (Or already have it included)
  • Added individualized logging for a debug or verbose mode that could be helpful in debugging and filtering out logs for user-level
  • Now uses discord.com instead of discordapp.com where applicable (New endpoint)
  • Added support for partyPrivacy and the buttons array
  • Added support for MacOS, as well as locating the ipc pipe from the Snap and Flatpak Distributions of Discord
    • Note that Flatpak'd JVMs are unable to locate the IPC Pipe, unless also using a Flatpak distribution of Discord, due to sandboxing restrictions.

CDAGaming added a commit to CDAGaming/CraftPresence-Mirror that referenced this pull request Sep 25, 2022
- Planning to merge the IPC data back into the origin as jagrosh/DiscordIPC#24 so this refactor just ensures it goes to that.
- IPC logging is also visually distinct with this change, as it is not using log4j
- Broke it during initial refactoring
- I truly don't know what past me was on going away from this, chief.
@jagrosh
Copy link
Owner

jagrosh commented Oct 12, 2022

There's a lot to unpack here. While there are plenty of changes in this that I'd love to see get merged in, there's also a lot that I don't think should be added. This isn't a comprehensive list or review, but just a start for some of the things I think should be removed before this could be merged:

  • Git/env/ci-related files, which seem tied more to your environment or build process than this project.
  • Gradle, I find for the scope of this project maven is simpler to use.
  • Main.java, which shouldn't be present in a library. JUnit tests would be fine if you need an executable test file.
  • [ ... more things as I notice them ... ]

@CDAGaming
Copy link
Author

@jagrosh Any way we can get the ball rolling again on this PR, considering the recent fixes being made and the breaking API change discord has planned with the Pomelo Updates.

- Allow freely changing the Debug and Verbose Log Settings (Primarily for better debugging mid-app-run / frontend configurability)
- Make IPCClient-Reader a daemon thread to avoid halting JVM exit
- This change integrates the Backoff logic from the Official RPC SDK, so that in the event of a disconnection, the Client will attempt to reconnect in subsequent `connect` executions, with increasing delays between `0.5 seconds` and `one minute`
- This only changes the behavior for an unexpected disconnection (Such as sending a Presence update while not connected to the RPC), it does not impact  a manual close (`onClose`)
- Added a `nickname` field to the user object, with a getter
- `name` field renamed to `username` (`getName` remains the same name for compatibility)
- Added `getEffectiveName` to retrieve the best display name (`username` if nickname is null, otherwise `nickname`)
…global_name`

- This further refines the future-proofing, and fixes an issue that can occur with no global name
- Use Lenni Reflect to reflect without needing add-opens
- Also updated plugins, and recall Java 7 Support
- Updated SLF4J to 2.0.10 (Was 2.0.7)
- Updated JUnixSocket to 2.8.3 (Was 2.7.0)
- Updated Lenni Reflect to 1.3.2 (Was 1.2.4)
- Updated Maven Javadoc Plugin to 3.6.3 (Was 3.5.0)
- Updated SLF4J-API to 2.0.12 (Was 2.0.10)
- Updated JUnixSocket to 2.9.0 (Was 2.8.3)
- Updated JUnixSocket to 2.9.1 (Was 2.9.0)
- Updated SLF4J to 2.0.13 (Was 2.0.12)
- Updated Lenni Reflect (1.3.2 -> 1.3.4)
- Updated GSON (2.10.1 -> 2.11.0)
- Should fix support for Java 22 on Windows, where this issue came up
- `Thread.sleep` call now matches all the others
- Adjusted the `WindowsPipe` to throw a proper `RuntimeException` in cases where we are unable to write to a IPC pipe (There is a difference from `exists` to `can read/write`)
  - A commit awhile ago broke the prior behavior, allowing the Pipe to be written to, causing another exception later. This change lets it fail more safely and as expected
- Clarified the error message for when an `IOException` is thrown for the Mac/Unix pipes
  - Its a bit vague since it triggers under almost any type of operation failure
- Replaced a `printStackTrace` call in `IPCClient#connect` for autoRegister behavior, so it'll now use the logger for the `debugMode` version
- Clarified error message for if the `WinRegistry` constructor fails
- No longer necessary
- No longer necessary
- Corrected documentation for several files
- Enforce Java 8+ behaviors, fully dropping Java 7 support (As tools exist now to handle downgrading)
- Added the 6th Default Avatar ID, which is only available to Migrated users
- Fixed `getDefaultAvatarId` for legacy users, and to more clearly represent discord documentation
- Fixed incorrect `commandKeyName` allocation
- Updated JUnixSocket (`2.9.1` -> `2.10.0`)
- Updated maven-javadoc-plugin (`3.6.3` -> `3.8.0`)
- Ported from another project I created
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants