mirror of
https://github.com/yuzu-emu/discord-rpc.git
synced 2024-12-22 23:35:38 +00:00
Move some stuff, hook up connect/disconnect cbs
This commit is contained in:
parent
47c488ac6b
commit
6d7e279074
|
@ -2,4 +2,5 @@ cmake_minimum_required (VERSION 3.7.0)
|
|||
project (DiscordRPCExample)
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(examples/simple)
|
||||
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 */
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#include "discord-rpc.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue