Moving files around; cleaned up example a little
This commit is contained in:
@ -1,3 +1,2 @@
|
||||
add_library(discord-rpc discord-rpc.cpp)
|
||||
add_executable(test-client simple.cpp)
|
||||
target_link_libraries(test-client discord-rpc)
|
||||
include_directories(${PROJECT_SOURCE_DIR}/include)
|
||||
add_library(discord-rpc STATIC discord-rpc.cpp)
|
||||
|
@ -1,61 +0,0 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
struct DiscordRichPresence {
|
||||
const char* state;
|
||||
const char* details;
|
||||
int64_t startTimestamp;
|
||||
int64_t endTimestamp;
|
||||
const char* largeImageKey;
|
||||
const char* largeImageText;
|
||||
const char* smallImageKey;
|
||||
const char* smallImageText;
|
||||
const char* partyId;
|
||||
int partySize;
|
||||
int partyMax;
|
||||
const char* matchSecret;
|
||||
const char* joinSecret;
|
||||
const char* spectateSecret;
|
||||
bool instance;
|
||||
};
|
||||
|
||||
struct DiscordEventHandlers {
|
||||
// required.
|
||||
void (*ready)();
|
||||
void (*disconnected)();
|
||||
|
||||
// optional for rich presence
|
||||
void (*wantsPresence)();
|
||||
void (*joinGame)(const char* joinSecret);
|
||||
void (*spectateGame)(const char* spectateSecret);
|
||||
};
|
||||
|
||||
void Discord_Initialize(const char* applicationId, DiscordEventHandlers* handlers);
|
||||
void Discord_Shutdown();
|
||||
void Discord_UpdatePresence(const DiscordRichPresence* presence);
|
||||
|
||||
/* later
|
||||
|
||||
struct DiscordChannelEventHandlers {
|
||||
void (*messageCreate)(const DiscordMessage* message);
|
||||
void (*messageUpdate)(const DiscordMessage* message);
|
||||
void (*messageDelete)(const DiscordMessage* message);
|
||||
void (*voiceStateCreate)(const DiscordVoiceState* state);
|
||||
void (*voiceStateDelete)(const DiscordVoiceState* state);
|
||||
void (*speakingStart)(const DiscordSpeakingState* state);
|
||||
void (*speakingStop)(const DiscordSpeakingState* state);
|
||||
};
|
||||
// Call this to subscribe to events in a specific voice or text channel
|
||||
void Discord_Subscribe(const char* channelId, const DiscordChannelEventHandlers* handlers);
|
||||
|
||||
// TBD RPC Requests
|
||||
void Discord_Authenticate();
|
||||
void Discord_Authorize();
|
||||
void Discord_GetGuilds();
|
||||
void Discord_GetChannels();
|
||||
void Discord_GetChannel();
|
||||
void Discord_SelectVoiceChannel();
|
||||
void Discord_SelectTextChannel();
|
||||
void Discord_SendMessage();
|
||||
|
||||
*/
|
@ -1,67 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "discord-rpc.h"
|
||||
|
||||
static const char* APPLICATION_ID = "12345678910";
|
||||
|
||||
void updateDiscordPresence() {
|
||||
DiscordRichPresence discordPresence{};
|
||||
|
||||
discordPresence.state = "In a Group";
|
||||
discordPresence.details = "Competitive\nIn a \"Match\"";
|
||||
discordPresence.endTimestamp = time(nullptr) + ((60 * 5) + 23);
|
||||
discordPresence.partyId = "12345";
|
||||
discordPresence.partySize = 3;
|
||||
discordPresence.partyMax = 6;
|
||||
discordPresence.matchSecret = "4b2fdce12f639de8bfa7e3591b71a0d679d7c93f";
|
||||
discordPresence.spectateSecret = "e7eb30d2ee025ed05c71ea495f770b76454ee4e0";
|
||||
discordPresence.instance = true;
|
||||
|
||||
Discord_UpdatePresence(&discordPresence);
|
||||
}
|
||||
|
||||
void handleDiscordReady() {
|
||||
printf("discord ready\n");
|
||||
}
|
||||
|
||||
void handleDiscordDisconnected() {
|
||||
printf("discord disconnected\n");
|
||||
}
|
||||
|
||||
void handleDiscordWantsPresence() {
|
||||
printf("discord requests presence\n");
|
||||
updateDiscordPresence();
|
||||
}
|
||||
|
||||
void gameLoop() {
|
||||
char line[512];
|
||||
printf("> ");
|
||||
fflush(stdout);
|
||||
while (fgets(line, 512, stdin)) {
|
||||
line[511] = 0;
|
||||
printf("I don't understand that.\n> ");
|
||||
fflush(stdout);
|
||||
|
||||
updateDiscordPresence();
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
printf("Starting game client\n");
|
||||
|
||||
DiscordEventHandlers handlers{};
|
||||
|
||||
handlers.ready = handleDiscordReady;
|
||||
handlers.disconnected = handleDiscordDisconnected;
|
||||
handlers.wantsPresence = handleDiscordWantsPresence;
|
||||
|
||||
Discord_Initialize(APPLICATION_ID, &handlers);
|
||||
|
||||
gameLoop();
|
||||
|
||||
Discord_Shutdown();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user