diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bf90d7..289bee7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,4 +2,5 @@ cmake_minimum_required (VERSION 3.7.0) project (DiscordRPCExample) add_subdirectory(src) +add_subdirectory(examples/simple) add_subdirectory(examples/simplest) diff --git a/examples/simple/simple.c b/examples/simple/simple.c index 73a1019..402d863 100644 --- a/examples/simple/simple.c +++ b/examples/simple/simple.c @@ -1,5 +1,5 @@ /* - This is a simple example in C of using the rich presence API syncronously. + This is a simple example in C of using the rich presence API asyncronously. */ #define _CRT_SECURE_NO_WARNINGS /* thanks Microsoft */ @@ -25,15 +25,15 @@ static void updateDiscordPresence() { } static void handleDiscordReady() { - printf("Discord: ready\n"); + printf("\nDiscord: ready\n"); } static void handleDiscordDisconnected() { - printf("Discord: disconnected\n"); + printf("\nDiscord: disconnected\n"); } static void handleDiscordWantsPresence() { - printf("Discord: requests presence\n"); + printf("\nDiscord: requests presence\n"); updateDiscordPresence(); } diff --git a/examples/simplest/CMakeLists.txt b/examples/simplest/CMakeLists.txt index 757ada0..97ba34f 100644 --- a/examples/simplest/CMakeLists.txt +++ b/examples/simplest/CMakeLists.txt @@ -1,3 +1,3 @@ include_directories(${PROJECT_SOURCE_DIR}/include) -add_executable(simplest-client simple.c) +add_executable(simplest-client simplest.c) target_link_libraries(simplest-client discord-rpc-simple) diff --git a/examples/simplest/simple.c b/examples/simplest/simplest.c similarity index 100% rename from examples/simplest/simple.c rename to examples/simplest/simplest.c diff --git a/src/discord-rpc.cpp b/src/discord-rpc.cpp index dd09c5c..1d3cece 100644 --- a/src/discord-rpc.cpp +++ b/src/discord-rpc.cpp @@ -1,7 +1,5 @@ #include "discord-rpc.h" -#include - #include "connection.h" #include "yolojson.h" @@ -20,6 +18,8 @@ void Discord_Initialize(const char* applicationId, DiscordEventHandlers* handler } MyConnection = RpcConnection::Create(); + MyConnection->onConnect = Handlers.ready; + MyConnection->onDisconnect = Handlers.disconnected; MyConnection->Open(); } diff --git a/src/yolojson.h b/src/yolojson.h index 34f315f..c045105 100644 --- a/src/yolojson.h +++ b/src/yolojson.h @@ -1,5 +1,10 @@ #pragma once +/* + This is as simple of a json writing thing as possible; does not try to keep you + from overflowing buffer, so make sure you have room. +*/ + // if only there was a standard library function for this inline size_t StringCopy(char* dest, const char* src, size_t maxBytes = UINT32_MAX) { if (!dest || !src || !maxBytes) {