GithubHelp home page GithubHelp logo

discord / discord-rpc Goto Github PK

View Code? Open in Web Editor NEW
1.0K 48.0 322.0 2.74 MB

Home Page: https://discordapp.com/developers

License: MIT License

CMake 8.17% C 5.00% C++ 68.59% Python 14.49% Objective-C 3.76%

discord-rpc's Introduction

Discord RPC

Deprecation Notice

This library has been deprecated in favor of Discord's GameSDK. Learn more here


This is a library for interfacing your game with a locally running Discord desktop client. It's known to work on Windows, macOS, and Linux. You can use the lib directly if you like, or use it as a guide to writing your own if it doesn't suit your game as is. PRs/feedback welcome if you have an improvement everyone might want, or can describe how this doesn't meet your needs.

Included here are some quick demos that implement the very minimal subset to show current status, and have callbacks for where a more complete game would do more things (joining, spectating, etc).

Documentation

The most up to date documentation for Rich Presence can always be found on our developer site! If you're interested in rolling your own native implementation of Rich Presence via IPC sockets instead of using our SDK—hey, you've got free time, right?—check out the "Hard Mode" documentation.

Basic Usage

Zeroith, you should be set up to build things because you are a game developer, right?

First, head on over to the Discord developers site and make yourself an app. Keep track of Client ID -- you'll need it here to pass to the init function.

Unreal Engine 4 Setup

To use the Rich Presense plugin with Unreal Engine Projects:

  1. Download the latest release for each operating system you are targeting and the zipped source code
  2. In the source code zip, copy the UE plugin—examples/unrealstatus/Plugins/discordrpc—to your project's plugin directory
  3. At [YOUR_UE_PROJECT]/Plugins/discordrpc/source/ThirdParty/DiscordRpcLibrary/, create an Include folder and copy discord_rpc.h and discord_register.h to it from the zip
  4. Follow the steps below for each OS
  5. Build your UE4 project
  6. Launch the editor, and enable the Discord plugin.

Windows

  • At [YOUR_UE_PROJECT]/Plugins/discordrpc/source/ThirdParty/DiscordRpcLibrary/, create a Win64 folder
  • Copy lib/discord-rpc.lib and bin/discord-rpc.dll from [RELEASE_ZIP]/win64-dynamic to the Win64 folder

Mac

  • At [YOUR_UE_PROJECT]/Plugins/discordrpc/source/ThirdParty/DiscordRpcLibrary/, create a Mac folder
  • Copy libdiscord-rpc.dylib from [RELEASE_ZIP]/osx-dynamic/lib to the Mac folder

Linux

  • At [YOUR_UE_PROJECT]/Plugins/discordrpc/source/ThirdParty/DiscordRpcLibrary/, create a Linux folder
  • Inside, create another folder x86_64-unknown-linux-gnu
  • Copy libdiscord-rpc.so from [RELEASE_ZIP]/linux-dynamic/lib to Linux/x86_64-unknown-linux-gnu

Unity Setup

If you're a Unity developer looking to integrate Rich Presence into your game, follow this simple guide to get started towards success:

  1. Download the DLLs for any platform that you need from our releases
  2. In your Unity project, create a Plugins folder inside your Assets folder if you don't already have one
  3. Copy the file DiscordRpc.cs from here into your Assets folder. This is basically your header file for the SDK

We've got our Plugins folder ready, so let's get platform-specific!

Windows

  1. Create x86 and x86_64 folders inside Assets/Plugins/
  2. Copy discord-rpc-win/win64-dynamic/bin/discord-rpc.dll to Assets/Plugins/x86_64/
  3. Copy discord-rpc-win/win32-dynamic/bin/discord-rpc.dll to Assets/Plugins/x86/
  4. Click on both DLLs and make sure they are targetting the correct architectures in the Unity editor properties pane
  5. Done!

MacOS

  1. Copy discord-rpc-osx/osx-dynamic/lib/libdiscord-rpc.dylib to Assets/Plugins/
  2. Rename libdiscord-rpc.dylib to discord-rpc.bundle
  3. Done!

Linux

  1. Copy discord-rpc-linux/linux-dynamic-lib/libdiscord-rpc.so to Assets/Plugins/
  2. Done!

You're ready to roll! For code examples on how to interact with the SDK using the DiscordRpc.cs header file, check out our example

From package

Download a release package for your platform(s) -- they have subdirs with various prebuilt options, select the one you need add /include to your compile includes, /lib to your linker paths, and link with discord-rpc. For the dynamically linked builds, you'll need to ship the associated file along with your game.

From repo

First-eth, you'll want CMake. There's a few different ways to install it on your system, and you should refer to their website. Many package managers provide ways of installing CMake as well.

To make sure it's installed correctly, type cmake --version into your flavor of terminal/cmd. If you get a response with a version number, you're good to go!

There's a CMake file that should be able to generate the lib for you; Sometimes I use it like this:

    cd <path to discord-rpc>
    mkdir build
    cd build
    cmake .. -DCMAKE_INSTALL_PREFIX=<path to install discord-rpc to>
    cmake --build . --config Release --target install

There is a wrapper build script build.py that runs cmake with a few different options.

Usually, I run build.py to get things started, then use the generated project files as I work on things. It does depend on click library, so do a quick pip install click to make sure you have it if you want to run build.py.

There are some CMake options you might care about:

flag default does
ENABLE_IO_THREAD ON When enabled, we start up a thread to do io processing, if disabled you should call Discord_UpdateConnection yourself.
USE_STATIC_CRT OFF (Windows) Enable to statically link the CRT, avoiding requiring users install the redistributable package. (The prebuilt binaries enable this option)
BUILD_SHARED_LIBS OFF Build library as a DLL
WARNINGS_AS_ERRORS OFF When enabled, compiles with -Werror (on *nix platforms).

Continuous Builds

Why do we have three of these? Three times the fun!

CI badge
TravisCI Build status
AppVeyor Build status
Buildkite (internal) Build status

Sample: send-presence

This is a text adventure "game" that inits/deinits the connection to Discord, and sends a presence update on each command.

Sample: button-clicker

This is a sample Unity project that wraps a DLL version of the library, and sends presence updates when you click on a button. Run python build.py unity in the root directory to build the correct library files and place them in their respective folders.

Sample: unrealstatus

This is a sample Unreal project that wraps the DLL version of the library with an Unreal plugin, exposes a blueprint class for interacting with it, and uses that to make a very simple UI. Run python build.py unreal in the root directory to build the correct library files and place them in their respective folders.

Wrappers and Implementations

Below is a table of unofficial, community-developed wrappers for and implementations of Rich Presence in various languages. If you would like to have yours added, please make a pull request adding your repository to the table. The repository should include:

  • The code
  • A brief ReadMe of how to use it
  • A working example
Rich Presence Wrappers and Implementations
Name Language
Discord RPC C# C#
Discord RPC D D
discord-rpc.jar Java
java-discord-rpc Java
Discord-IPC Java
Discord Rich Presence JavaScript
drpc4k Kotlin
lua-discordRPC LuaJIT (FFI)
pypresence Python
SwordRPC Swift

discord-rpc's People

Contributors

0xeab avatar arsenarsen avatar azoy avatar crmarsh avatar derwodaso avatar devsnek avatar enkoder avatar iceninjaman avatar intelorca avatar jagrosh avatar janisozaur avatar jasoncitron avatar judge2020 avatar k1-801 avatar kennyrkun avatar lachee avatar max-kamps avatar minndevelopment avatar msciotti avatar olvrb avatar pfirsich avatar qwertyquerty avatar sk83rjosh avatar sliv9 avatar sll552 avatar snowyote avatar the-disco-option avatar thejhnz avatar yalter avatar yourwaifu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

discord-rpc's Issues

Allowing upload of assets via Hash

So, I'm working on a neat little feature that lets a game create images based on the current state of the game. But since the Rich Presence is restricted to pre-uploaded assets of the application used, I am in quite a pickle. Wouldn't it allow for more options to allow the DiscordRPC to upload pictures via a hash-key of the picture, instead of relying on pre-uploded assets? The profile pictures are send like that on a JoinRequest, so I doubt it should be that hard to allow it the other way around.

[Suggestion] Version number to check against

Would it be possible to add a version we can check against for those of us using the win32-dynamic build?

For example, if we implement something that requires at minimum v2.1.0, there should be a way to check that the user has a DLL that meets the minimum version. Here's how it could be potentially implemented:

DISCORD_EXPORT float Discord_GetVersion(void) const;

Usage:

if (Discord_GetVersion() < 2.1f) {
  Error("Your Discord RPC plugin is out of date, please update it and try again.");
}

This would ensure any projects relying on the dynamic branch (which may require users to download the DLL manually) will continue to work correctly, without having to resort to customer feedback of "why isn't X working?!" -- unless this is guaranteed to never happen, of course!

Need some way to tell Discord what command line parameters joining players need to use.

To quote my comment on issue #35: "Of course, I could avoid this, and any other issues altogether if there were a way to set what command line arguments are to be used when another player launches the game through Discord. (ie. Some way to tell their Discord client they'll need to launch the game with "/g mymod.pk3 /n:0 123.231.213.132", like some .partycmd field in the discordPresence struct or something.)"

In short, this feature, would render issue #35 a moot point for me.

Launching Steam games on Linux doesn't work (at least without a DE)

We register a desktop file containing xdg-open steam://rungameid/<number> %u, but it turns out that when we do xdg-open discord-<number>:// it actually runs xdg-open steam://rungameid/<number> discord-<number>:// (so it appends the original "url") and then complains about the second argument (since there's only supposed to be one argument to xdg-open).

Not sure how to handle this (is there a way to prevent that argument from getting appended?). Looking at the xdg-open source, for me (no DE, maybe that's the problem) the final line that executes the command is "$command_exec" "$@" where $command_exec turns out to be xdg-open steam://rungameid/<number> (from the .desktop file), and $@ is discord-<number>://.

Nvm.

Nevermind. I figured out.

Compile errors in VS 2017

I've manually created a VS 2017 project (without cmake) to compile discord-rpc for statically linking with my game (I need specific compiler settings for static linking to work)

I'm getting a bunch of compile errors in discord_register_win.cpp because it includes psapi.h before windows.h - types like BOOL, DWORD and WINAPI aren't defined apparently - swapping the order to include windows.h first fixes the compile errors.

Did you chose this include order with a particular reason in mind or did I miss something while creating my project file? Or is this actually an oversight and discord currently does not compile in VS 2017 without this fix?

Unity Example does not connect to discord

When launching Unity example it shows in log:

"Discord: init",
"Discord: on click!"

On exit: "Discord: shutdown"

No message "Discord: ready". It shows also "Discord Disconnected". No other messages or errors in log.
Tried from latest master, also tried library replacement from released archive zip - the same result

Unable to compile Unreal Example project

Hello,

I am currently trying to get the Unreal Example running, but I am running into issues.
I have placed the .lib file in \Source\ThirdParty\discordrpcLibrary\x64\Release, but I get these errors when compiling

Module.discordrpc.cpp.obj
: error LNK2019: unresolved external symbol __imp_Discord_Initialize referenced in function "public: void __cdecl UDiscordRpc::Initialize(class FString const &,bool,class FString const &)" (?Initialize@UDiscordRpc@@QEAAXAEBVFString@@_N0@Z)
2>Module.discordrpc.cpp.obj : error LNK2019: unresolved external symbol __imp_Discord_Shutdown referenced in function "public: void __cdecl UDiscordRpc::Shutdown(void)" (?Shutdown@UDiscordRpc@@QEAAXXZ)
2>Module.discordrpc.cpp.obj : error LNK2019: unresolved external symbol __imp_Discord_RunCallbacks referenced in function "public: void __cdecl UDiscordRpc::RunCallbacks(void)" (?RunCallbacks@UDiscordRpc@@QEAAXXZ)
2>Module.discordrpc.cpp.obj : error LNK2019: unresolved external symbol __imp_Discord_UpdatePresence referenced in function "public: void __cdecl UDiscordRpc::UpdatePresence(void)" (?UpdatePresence@UDiscordRpc@@QEAAXXZ)
2>C:\Users\Administrator\Downloads\discord-rpc-master(1)\discord-rpc-master\examples\unrealstatus\Plugins\discordrpc\Binaries\Win64\UE4Editor-discordrpc.dll : fatal error LNK1120: 4 unresolved externals

I tried to solve this by adding PublicIncludePaths.Add(Path.Combine(ModuleDirectory, "Include")); to discordrpcLibrary.Build.cs and copy discord-rpc.h from the include dir into it, but it still won't find it.

How does one resolve this error? It looks like it doesn't find the additional header file to me.
I am using the win64-static lib.

Crash during shutdown (documentation bug)

The documentation over at discord does not mention that you have to call Discord_Shutdown even though it is vital for a clean shutdown.

If you don't call Discord_Shutdown then the application does not shut down properly. You have a static variable of type std::thread which will run its destructor during termination of the application. Running a destructor on a running thread is not allowed and will crash the program (calls std::terminate)

This prevents a clean exit because other destructors and onexit handlers are not executed.

You apparently have Discord_Shutdown which properly terminates the thread, allowing clean shutdown of the game, but you haven't mentioned this anywhere in your documentation.

Add support for Mingw compilations

It looks like the current solution doesn't compile with CMake with mingw compilers, meaning a cross-compilation from Linux to Windows doesn't work.

Discord_Shutdown does not unset Discord user's Playing status

For both the send-presence sample and our own integration, a call to Discord_Shutdown does not call the disconnect handler, and the Playing <game> status in Discord stays there for the user even after the process has been shut down. Calling Discord_UpdateConnection() and Discord_RunCallbacks() after Discord_Shutdown() (to really cover all our bases) didn't work either. The only fix for this is restarting Discord client-side; the RP status disappears then. Time doesn't seem to play a role either, as the RP just stays there.

The send-presence sample that was tested was taken from the 2.0.1 release of this repo. For our own integration, discord-rpc was compiled as a 32-bit DLL from the master source as of commit 5d5bc82 on a Win 7 64-bit machine:

cmake .. -DCMAKE_INSTALL_PREFIX=..\out -DBUILD_SHARED_LIBS=ON -DUSE_STATIC_CRT=ON -DENABLE_IO_THREAD=OFF -G "Visual Studio 14 2015"

[Request] Function to send callback to party host that joining player has loaded app and is ready.

In my frontend for Duke3D, I would like a way for joining players to able to signal to the host that they've managed to launch the app and are ready (something like Discord_JoinCompleted() that I can stick in joinGame somewhere), so that the host running the frontend can increment the party size accordingly at the appropriate time, and close the app if the party size is reached. (As by then the frontend would launch the game already, and is no longer needed).

Reason I ask this, is I can't increment the party size in the joinRequest callback, as it can cause a race condition, where the party is signaled as being full, or the frontend quits before the joining player's discord acknowledges that they've been accepted into the match, cancelling the join request for them. I could create my own signal back through winsocks, or some other socket library, but that is a royal pain.

The last option is just not updating the party size, and keeping the frontend running while the game itself is waiting for connections, but that allows people to attempt joining when the party is already full and the game is in progress, which is far from good. (And what I'm doing right now just to make it usable.)

Lastly, I'd like an equivalent of "joinRequest" when players just join through invites. Just so I can update the state of the frontend when people join.

Missing discriminator for DiscordJoinRequest

The payload for ACTIVITY_JOIN_REQUEST contains a full user object (exluding account security/type details) however it reads only username, user_id, and avatar.
The discriminator is incredibly helpful for apps to be specific about what user wants to join.

Was this intentionally left out?
See Section

Example

{
    "evt":"ACTIVITY_JOIN_REQUEST",
    "data": {
        "user": {
            "avatar":"e7032e1e1e602cd5123488da2a75f041",
            "id":"86699011792191488",
            "discriminator":"6688",
            "username":"Minn"
        }
    },
    "cmd":"DISPATCH",
    "nonce":null
}

Ingame personal inviting

Any way to invite a specific person and have that person be able to accept that invite ingame? If there isn't, this might be something useful to add. Right now you need to press the joim button inside Discord to accept an invite, which works great for groups but is kinda annoying per person.

I'm assuming you need to be able to get your friends list somehow.

Allow setting Rich Presence activity types via RPC

Right now, RPC rich presence clients don't allow to set activity types, however, this should be possible, because many people are making apps for music and other integrations using RPC. Also, since devs have clarified that these apps are allowed, having (especially) the "listening to" type would be beneficial.

Windows XP "support"

Yes, I know, Windows XP, EOL and whatnot, but my game supports Windows XP and some people for whatever reason still play on Windows XP. I link discord-rpc statically and due to its usage of the RegSetKeyValueW API call the game fails to start.

Perhaps it's possible to replace it with a call that exists on Windows XP, or load it dynamically? This would also allow to get rid of the MINGW Vista defines at the top of that file.

If this is out of scope of this repository, I'll come up with something myself.

Join Request callback firing with empty data on 32-bit DLL (Unity)

The game I am working on currently only uses a 32-bit build, but I seem to have an issue with the 32-bit DLL.

When receiving the "join request" callback from another user asking to join, the data packet received is always completely empty. I tried this using the button-clicker example, creating two builds (32-bit and 64-bit) with the 2.0.1 release.

Both builds will fire off the "join request" callback but only the 64-bit will have data.

e.g:
from the logs from the 64-bit version:
Discord: join request [username]: [userid]

on the 32-bit version, I just get the basic printout with no values
Discord: join request :

In my actual game the data is also not there with the 32-bit DLL and after trying to use these null values the whole application crashes. It works fine with the 64-bit DLL.

I'm using Unity 2017.1.1.p2

Some joining players don't fire join callbacks.

Seems for some reason, and only for some users, the Discord desktop client doesn't launch my app when they get a "yes" response from it in the join request handler. Even if they have the game registered fully, and added to their "games" list in Discord.

Linux Unity Support

In the Unity example, there is only a Windows DLL (Unity won't give options to include it with Linux). Will there be Linux support eventually?

Unreal example project Solution doesn't compile

Error at:

Plugins\discordrpc\Source\discordrpc\Public\DiscordRpcBlueprint.h

Caused due to the include "DiscordRpcBlueprint.generated.h" not being at the end of the includes.

Build succeeds once moving that line to the bottom of the includes.

Binary files in repository

This repository seems to contain multiple binaries. Such files are not meant to be stored in a git repository, they don't compress very well and degrade git performance.

I would urge to stop storing them here and rather rely on fetching (manually or automatically) released versions from https://github.com/discordapp/discord-rpc/releases or using Git-LFS fallback (but that comes with some limitations on GitHub when used with free tier).

[Unity] Using DiscordRpc.Respond returns code 4012 "no join request for that user"

Currently trying to add Discord RPC to our game in Unity and for some reason DiscordRpc.Respond always ends up popping an error with code 4012, even when my requestCallback is simple (view example below).

private void OnRequestCallback(DiscordRpc.JoinRequest request)
{
    DiscordRpc.Respond(request.userId, DiscordRpc.Reply.Yes);
}

My party stats are setup properly (partyId, partySize, partyMax) and my joinSecret is set to my partyId but encrypted with aes256.

The request to join button is shown properly to another user that's been added as a test user of our app.

That error code doesn't make much sense either considering I'm responding to a request callback.

OSX and Linux Libraries in Release Package?

The current packages currently only include Windows 32-bit and 64-bit DLLs. As the library (in theory?) supports OSx and Linux, is there a reason prebuilt versions aren't available? As a Unity developer it would make implementation orders of magnitude simpler if they were available as well as Windows builds.

Thanks!

Steam custom game mod support

Hello, as far as I can tell replacing steam://run/ with steam://rungameid/ in Discord_RegisterSteamGame makes it possible to additionally launch Steam custom game mods (which you can't launch otherwise because they don't have a Steam ID). This is important for me as I want to add support to a Half-Life mod which is not on the Steam store.

Includes needed re-ordering to successfully compile

I had to re-order the includes in discord_register_win.cpp in order to successfully compile as Psapi.h assumes windows.h has already been included:

#include <windows.h>
#include <Psapi.h>
#include <Strsafe.h>

Error at LSSetDefaultHandlerForURLScheme() (OSStatus -54)

Using Xcode, I am linking the compiled lib in my native Objective-C++ based app. Line 67 of discord_register_osx.m is creating an error, OSStatus -54. This is the code for insufficient privileges usually (i.e., when you try to open a file you aren't allowed), so I'm not sure how this is happening. No clue why, of all things, LSSetDefaultHandlerForURLScheme() would be doing this. Also of note: I don't think this is an issue with the example, though I never have been able to get it to run properly in the first place.

Constructued DiscordRPC class gets destroyed when doing anything related to Sessions in Unreal Engine.

When hosting or joining a session. The DiscordRPC class gets destroyed/becomes invalid and it won't be able to send presences or check for callbacks anymore. OnDisconnected & OnErrored does not fire either when this happens.

However, if you construct the class again after it's become invalid everything seems to work like normal again. OnConnected does not re-fire when you reconstruct the class.

C# Example/Wrapper

The C# wrapper for the Discord RPC SDK is flawed in the RequestCallback. It should be ref DiscordRpc.JoinRequest request instead of DiscordRpc.JoinRequest request.

Use discord-rpc on Qt

I'm trying to export the lib to the Qt IDE, and use it, I add the folder to the project's folder and add this to the .pro file:

INCLUDEPATH += discord-rpc/include

LIBS += -L"discord-rpc/lib/discord-rpc.lib"

when I try to include the discord-rpc.h in my main file the functions of the lib don't work

image

when I type ctrl and click in the included file, in the line #include "discord-rpc.h", I go to the file discord-rpc.h, but the functions don't work on the main file.

What is happening?

macOS Compilation Issue

Having trouble compiling on macOS. Any pointer in the right direction would be appreciated. Let me know if there's any information that could be helpful.

cmake version

cmake --version
cmake version 3.7.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).

clang version

clang -v
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin16.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
cmake --build . --config Release --target install
Scanning dependencies of target clangformat
[  0%] Built target clangformat
Scanning dependencies of target discord-rpc
[ 12%] Building CXX object src/CMakeFiles/discord-rpc.dir/discord-rpc.cpp.o
In file included from /Users/m/88dots/discord-rpc/src/discord-rpc.cpp:5:
In file included from /Users/m/88dots/discord-rpc/src/rpc_connection.h:3:
/Users/m/88dots/discord-rpc/src/connection.h:14:10: error: function definition does not declare parameters
    bool isOpen{false};
         ^
In file included from /Users/m/88dots/discord-rpc/src/discord-rpc.cpp:5:
In file included from /Users/m/88dots/discord-rpc/src/rpc_connection.h:4:
/Users/m/88dots/discord-rpc/src/serialization.h:95:16: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
    using Ch = char;
               ^
/Users/m/88dots/discord-rpc/src/serialization.h:117:25: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using MallocAllocator = rapidjson::CrtAllocator;
                        ^
/Users/m/88dots/discord-rpc/src/serialization.h:118:23: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using PoolAllocator = rapidjson::MemoryPoolAllocator<MallocAllocator>;
                      ^
/Users/m/88dots/discord-rpc/src/serialization.h:119:14: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using UTF8 = rapidjson::UTF8<char>;
             ^
/Users/m/88dots/discord-rpc/src/serialization.h:121:24: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using StackAllocator = FixedLinearAllocator<2048>;
                       ^
/Users/m/88dots/discord-rpc/src/serialization.h:122:1: error: unknown type name 'constexpr'
constexpr size_t WriterNestingLevels = 2048 / (2 * sizeof(size_t));
^
/Users/m/88dots/discord-rpc/src/serialization.h:122:17: error: expected ';' after top level declarator
constexpr size_t WriterNestingLevels = 2048 / (2 * sizeof(size_t));
                ^
                ;
/Users/m/88dots/discord-rpc/src/serialization.h:124:3: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
  rapidjson::Writer<DirectStringBuffer, UTF8, UTF8, StackAllocator, rapidjson::kWriteNoFlags>;
  ^
/Users/m/88dots/discord-rpc/src/serialization.h:131:53: error: use of undeclared identifier 'WriterNestingLevels'
      : JsonWriterBase(stringBuffer_, &stackAlloc_, WriterNestingLevels)
                                                    ^
/Users/m/88dots/discord-rpc/src/serialization.h:140:26: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using JsonDocumentBase = rapidjson::GenericDocument<UTF8, PoolAllocator, StackAllocator>;
                         ^
/Users/m/88dots/discord-rpc/src/serialization.h:161:19: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using JsonValue = rapidjson::GenericValue<UTF8, PoolAllocator>;
                  ^
/Users/m/88dots/discord-rpc/src/serialization.h:166:9: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
        auto member = obj->FindMember(name);
        ^
/Users/m/88dots/discord-rpc/src/serialization.h:177:9: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
        auto member = obj->FindMember(name);
        ^
/Users/m/88dots/discord-rpc/src/serialization.h:190:9: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
        auto member = obj->FindMember(name);
        ^
In file included from /Users/m/88dots/discord-rpc/src/discord-rpc.cpp:5:
/Users/m/88dots/discord-rpc/src/rpc_connection.h:8:1: error: unknown type name 'constexpr'
constexpr size_t MaxRpcFrameSize = 64 * 1024;
^
/Users/m/88dots/discord-rpc/src/rpc_connection.h:8:17: error: expected ';' after top level declarator
constexpr size_t MaxRpcFrameSize = 64 * 1024;
                ^
                ;
/Users/m/88dots/discord-rpc/src/rpc_connection.h:11:10: warning: scoped enumerations are a C++11 extension [-Wc++11-extensions]
    enum class ErrorCode : int {
         ^
/Users/m/88dots/discord-rpc/src/rpc_connection.h:11:16: error: ISO C++ forbids forward references to 'enum' types
    enum class ErrorCode : int {
               ^
/Users/m/88dots/discord-rpc/src/rpc_connection.h:11:32: error: expected '(' for function-style cast or type construction
    enum class ErrorCode : int {
                           ~~~ ^
/Users/m/88dots/discord-rpc/src/rpc_connection.h:17:10: warning: scoped enumerations are a C++11 extension [-Wc++11-extensions]
    enum class Opcode : uint32_t {
         ^
/Users/m/88dots/discord-rpc/src/rpc_connection.h:17:16: error: ISO C++ forbids forward references to 'enum' types
    enum class Opcode : uint32_t {
               ^
/Users/m/88dots/discord-rpc/src/rpc_connection.h:17:34: error: expected '(' for function-style cast or type construction
    enum class Opcode : uint32_t {
                        ~~~~~~~~ ^
/Users/m/88dots/discord-rpc/src/rpc_connection.h:31:22: error: use of undeclared identifier 'MaxRpcFrameSize'
        char message[MaxRpcFrameSize - sizeof(MessageFrameHeader)];
                     ^
/Users/m/88dots/discord-rpc/src/rpc_connection.h:34:10: warning: scoped enumerations are a C++11 extension [-Wc++11-extensions]
    enum class State : uint32_t {
         ^
/Users/m/88dots/discord-rpc/src/rpc_connection.h:34:16: error: ISO C++ forbids forward references to 'enum' types
    enum class State : uint32_t {
               ^
/Users/m/88dots/discord-rpc/src/rpc_connection.h:34:33: error: expected '(' for function-style cast or type construction
    enum class State : uint32_t {
                       ~~~~~~~~ ^
/Users/m/88dots/discord-rpc/src/rpc_connection.h:41:21: error: function definition does not declare parameters
    BaseConnection* connection{nullptr};
                    ^
/Users/m/88dots/discord-rpc/src/rpc_connection.h:42:11: error: function definition does not declare parameters
    State state{State::Disconnected};
          ^
/Users/m/88dots/discord-rpc/src/rpc_connection.h:43:12: error: function definition does not declare parameters
    void (*onConnect)(){nullptr};
           ^
/Users/m/88dots/discord-rpc/src/rpc_connection.h:44:12: error: function definition does not declare parameters
    void (*onDisconnect)(int errorCode, const char* message){nullptr};
           ^
/Users/m/88dots/discord-rpc/src/rpc_connection.h:45:10: error: function definition does not declare parameters
    char appId[64]{};
         ^
/Users/m/88dots/discord-rpc/src/rpc_connection.h:46:9: error: function definition does not declare parameters
    int lastErrorCode{0};
        ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
14 warnings and 20 errors generated.
make[2]: *** [src/CMakeFiles/discord-rpc.dir/discord-rpc.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/discord-rpc.dir/all] Error 2
make: *** [all] Error 2

Need a way to check if discord is running, or have a callback run when discord isn't present when calling Discord_Initialize.

In my code, I have a loop like this:

	InitDiscord();
	while (discord_status == DISCORD_WAITING)
	{
		handleevents();
		Discord_RunCallbacks();
	}

Because I need to wait for Discord to be ready, before I can proceed with the rest of the game's startup (since multiplayer connections happen during this phase).

This loop works perfectly fine if Discord is running, it'll wait until Rich Presence is ready, and then proceed. (All the different handlers will change the value of DISCORD_STATUS, including the error callback.)

However, if Discord isn't running, there's no way to check this, not even the error callback fires, and thus the game just hangs here. I'd like to have some sort of callback or return value here.

[Linux] Can't compile without IO thread

Trying to compile the library with -DENABLE_IO_THREAD=OFF results in errors.

discord-rpc/build$ cmake -DBUILD_DYNAMIC_LIB=ON -DENABLE_IO_THREAD=OFF ..
-- Configuring done
-- Generating done
-- Build files have been written to: /home/max/Dropbox/projects/sublime-rpc/discord-rpc/build
discord-rpc/build$ make
[  0%] Built target clangformat
Scanning dependencies of target discord-rpc
[ 12%] Building CXX object src/CMakeFiles/discord-rpc.dir/discord-rpc.cpp.o
c++: error: discord-rpc: No such file or directory
c++: error: PUBLIC: No such file or directory
make[2]: *** [src/CMakeFiles/discord-rpc.dir/build.make:63: src/CMakeFiles/discord-rpc.dir/discord-rpc.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:118: src/CMakeFiles/discord-rpc.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
> 2

OnJoin doesn't fire in Unreal Engine 4.

I have set up a client which sends this presence data:

m7j5qlr

Then I made an invitation in Discord (as the user who started the game first)

dsasd

With a second Discord user I then press the Join button and the game launches for the second player, but the event doesn't get fired.

join

Using Process Explorer I also couldn't see any extra parameters passed to the client. How is the Join Secret passed to the game? Why is my event not being fired? Am I understanding something wrong here?

Errors with CMAKE_BUILD_TYPE=Release

CMAKE_BUILD_TYPE=Release builds stuff in Release mode on Linux (-O3 -DNDEBUG and whatnot), which results in the following errors (probably because assert is optimized out):

../src/serialization.h:75:25: error: unused parameter 'originalPtr' [-Werror,-Wunused-parameter]
    void* Realloc(void* originalPtr, size_t originalSize, size_t newSize)
                        ^
../src/serialization.h:75:45: error: unused parameter 'originalSize' [-Werror,-Wunused-parameter]
    void* Realloc(void* originalPtr, size_t originalSize, size_t newSize)
                                            ^

rapidjson conflict

Our project uses an older version of rapidjson and by including discord-rpc as a static linked library causes issues with the compiler not knowing which to use.

Although this was solved for us by dropping the same version of rapidjson in to our project. This may not be viable for others.

Images do not show

I'm using the example code provided in a C# project and everything is working fine except for the images, both large and small. I've uploaded them to the dashboard and am using the corresponding key (the name I gave the image, that shows up next to it post upload). I've yet to get any of the images to show.

presence.largeImageKey = "lobby";

image

image

Web API

Hi there;

First of all, great project!
I have an online game (foda.gq), it has a nodejs back-end
so it's 100% javascript - well there's also the css and html ;D
I would like to integrate it with Discord Rich Presence.
Is that possible? Can I help making it possible, how?

Thanks a lot!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.