Fixup event names

- GAME_XXXXX not XXXXX_GAME
- Nuked the WantsPresence event
This commit is contained in:
Jason Citron 2017-07-28 00:19:10 -07:00
parent 6338a572d3
commit 93d9ba10c2
3 changed files with 4 additions and 25 deletions

View file

@ -40,12 +40,6 @@ static void handleDiscordError(int errcode, const char* message)
printf("\nDiscord: error (%d: %s)\n", errcode, message);
}
static void handleDiscordPresenceRequested()
{
printf("\nDiscord: requests presence\n");
updateDiscordPresence();
}
static int prompt(char* line, size_t size)
{
int res;
@ -102,7 +96,6 @@ int main(int argc, char* argv[])
handlers.ready = handleDiscordReady;
handlers.disconnected = handleDiscordDisconnected;
handlers.errored = handleDiscordError;
handlers.presenceRequested = handleDiscordPresenceRequested;
Discord_Initialize(APPLICATION_ID, &handlers, 1);
gameLoop();

View file

@ -27,7 +27,6 @@ typedef struct DiscordEventHandlers {
void (*ready)();
void (*disconnected)(int errorCode, const char* message);
void (*errored)(int errorCode, const char* message);
void (*presenceRequested)();
void (*joinGame)(const char* joinSecret);
void (*spectateGame)(const char* spectateSecret);
} DiscordEventHandlers;

View file

@ -26,7 +26,6 @@ static DiscordEventHandlers Handlers{};
static std::atomic_bool WasJustConnected{false};
static std::atomic_bool WasJustDisconnected{false};
static std::atomic_bool GotErrorMessage{false};
static std::atomic_bool WasPresenceRequested{false};
static std::atomic_bool WasJoinGame{false};
static std::atomic_bool WasSpectateGame{false};
static char JoinGameSecret[256];
@ -117,17 +116,13 @@ extern "C" void Discord_UpdateConnection()
continue;
}
// todo ug
if (strcmp(evtName, "PRESENCE_REQUESTED") == 0) {
WasPresenceRequested.store(true);
}
else if (strcmp(evtName, "JOIN_GAME") == 0) {
if (strcmp(evtName, "GAME_JOIN") == 0) {
auto data = message.FindMember("data");
auto secret = data->value["secret"].GetString();
StringCopy(JoinGameSecret, secret);
WasJoinGame.store(true);
}
else if (strcmp(evtName, "SPECTATE_GAME") == 0) {
else if (strcmp(evtName, "GAME_SPECTATE") == 0) {
auto data = message.FindMember("data");
auto secret = data->value["secret"].GetString();
StringCopy(SpectateGameSecret, secret);
@ -201,16 +196,12 @@ extern "C" void Discord_Initialize(const char* applicationId,
WasJustConnected.exchange(true);
ReconnectTimeMs.reset();
if (Handlers.presenceRequested) {
RegisterForEvent("PRESENCE_REQUESTED");
}
if (Handlers.joinGame) {
RegisterForEvent("JOIN_GAME");
RegisterForEvent("GAME_JOIN");
}
if (Handlers.spectateGame) {
RegisterForEvent("SPECTATE_GAME");
RegisterForEvent("GAME_SPECTATE");
}
};
Connection->onDisconnect = [](int err, const char* message) {
@ -265,10 +256,6 @@ extern "C" void Discord_RunCallbacks()
Handlers.ready();
}
if (WasPresenceRequested.exchange(false) && Handlers.presenceRequested) {
Handlers.presenceRequested();
}
if (WasJoinGame.exchange(false) && Handlers.joinGame) {
Handlers.joinGame(JoinGameSecret);
}