Move some stuff, hook up connect/disconnect cbs
This commit is contained in:
parent
47c488ac6b
commit
6d7e279074
6 changed files with 13 additions and 7 deletions
|
@ -2,4 +2,5 @@ cmake_minimum_required (VERSION 3.7.0)
|
||||||
project (DiscordRPCExample)
|
project (DiscordRPCExample)
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
add_subdirectory(examples/simple)
|
||||||
add_subdirectory(examples/simplest)
|
add_subdirectory(examples/simplest)
|
||||||
|
|
|
@ -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 */
|
#define _CRT_SECURE_NO_WARNINGS /* thanks Microsoft */
|
||||||
|
@ -25,15 +25,15 @@ static void updateDiscordPresence() {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handleDiscordReady() {
|
static void handleDiscordReady() {
|
||||||
printf("Discord: ready\n");
|
printf("\nDiscord: ready\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handleDiscordDisconnected() {
|
static void handleDiscordDisconnected() {
|
||||||
printf("Discord: disconnected\n");
|
printf("\nDiscord: disconnected\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handleDiscordWantsPresence() {
|
static void handleDiscordWantsPresence() {
|
||||||
printf("Discord: requests presence\n");
|
printf("\nDiscord: requests presence\n");
|
||||||
updateDiscordPresence();
|
updateDiscordPresence();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
include_directories(${PROJECT_SOURCE_DIR}/include)
|
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)
|
target_link_libraries(simplest-client discord-rpc-simple)
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#include "discord-rpc.h"
|
#include "discord-rpc.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
#include "yolojson.h"
|
#include "yolojson.h"
|
||||||
|
|
||||||
|
@ -20,6 +18,8 @@ void Discord_Initialize(const char* applicationId, DiscordEventHandlers* handler
|
||||||
}
|
}
|
||||||
|
|
||||||
MyConnection = RpcConnection::Create();
|
MyConnection = RpcConnection::Create();
|
||||||
|
MyConnection->onConnect = Handlers.ready;
|
||||||
|
MyConnection->onDisconnect = Handlers.disconnected;
|
||||||
MyConnection->Open();
|
MyConnection->Open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
#pragma once
|
#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
|
// if only there was a standard library function for this
|
||||||
inline size_t StringCopy(char* dest, const char* src, size_t maxBytes = UINT32_MAX) {
|
inline size_t StringCopy(char* dest, const char* src, size_t maxBytes = UINT32_MAX) {
|
||||||
if (!dest || !src || !maxBytes) {
|
if (!dest || !src || !maxBytes) {
|
||||||
|
|
Loading…
Reference in a new issue