Rename a thing
This commit is contained in:
parent
827c056602
commit
6ea9c46f77
8 changed files with 39 additions and 7 deletions
|
@ -22,4 +22,4 @@ endif(NOT RAPIDJSON)
|
|||
add_library(rapidjson STATIC IMPORTED ${RAPIDJSON})
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(examples/simple)
|
||||
add_subdirectory(examples/send-presence)
|
||||
|
|
21
README.md
21
README.md
|
@ -1,8 +1,25 @@
|
|||
Discord RPC Sample
|
||||
==================
|
||||
# Discord RPC
|
||||
|
||||
This is a lib and a couple of quick demos, one that implements the very minimal subset to show
|
||||
current status, and one that is more complete. The idea here is to give you an lib that implements
|
||||
the rpc connection and wraps sending events, and a basic example that uses it; 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.
|
||||
|
||||
## Usage
|
||||
|
||||
There's a CMake file that should be able to generate the lib for you; I use it like this:
|
||||
```
|
||||
cd /path/to/discord-rpc
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
cmake --build .
|
||||
```
|
||||
Sometimes I use the generated project files.
|
||||
|
||||
## Sample: send-presence
|
||||
|
||||
This is a text adventure "game" that inits/deinits the connection to Discord, and sends a presence
|
||||
update on each command.
|
||||
|
|
3
examples/send-presence/CMakeLists.txt
Normal file
3
examples/send-presence/CMakeLists.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
include_directories(${PROJECT_SOURCE_DIR}/include)
|
||||
add_executable(send-presence send-presence.c)
|
||||
target_link_libraries(send-presence discord-rpc)
|
|
@ -1,3 +0,0 @@
|
|||
include_directories(${PROJECT_SOURCE_DIR}/include)
|
||||
add_executable(simple-client simple.c)
|
||||
target_link_libraries(simple-client discord-rpc)
|
|
@ -35,7 +35,6 @@ typedef struct DiscordEventHandlers {
|
|||
|
||||
void Discord_Initialize(const char* applicationId, DiscordEventHandlers* handlers);
|
||||
void Discord_Shutdown();
|
||||
void Discord_UpdatePresence(const DiscordRichPresence* presence);
|
||||
|
||||
/* checks for incoming messages, dispatches callbacks */
|
||||
void Discord_RunCallbacks();
|
||||
|
@ -45,6 +44,8 @@ void Discord_RunCallbacks();
|
|||
void Discord_UpdateConnection();
|
||||
#endif
|
||||
|
||||
void Discord_UpdatePresence(const DiscordRichPresence* presence);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
|
|
@ -78,6 +78,19 @@ extern "C" void Discord_UpdateConnection()
|
|||
while (Connection->Read(message)) {
|
||||
// todo: do something...
|
||||
printf("Hey, I got a message\n");
|
||||
|
||||
// expect cmd, data, evt, nonce here?
|
||||
|
||||
/*
|
||||
message.FindMember("cmd");
|
||||
message.FindMember("data");
|
||||
message.FindMember("evt");
|
||||
message.FindMember("nonce"); // in responses only
|
||||
|
||||
void(*presenceRequested)();
|
||||
void(*joinGame)(const char* joinSecret);
|
||||
void(*spectateGame)(const char* spectateSecret);
|
||||
*/
|
||||
}
|
||||
|
||||
// writes
|
||||
|
|
|
@ -19,6 +19,7 @@ inline size_t StringCopy(char (&dest)[Len], const char* src) {
|
|||
|
||||
size_t JsonWriteHandshakeObj(char* dest, size_t maxLen, int version, const char* applicationId);
|
||||
|
||||
// Commands
|
||||
struct DiscordRichPresence;
|
||||
size_t JsonWriteRichPresenceObj(char* dest, size_t maxLen, int nonce, int pid, const DiscordRichPresence* presence);
|
||||
|
||||
|
|
Loading…
Reference in a new issue