Start on adding update function
This commit is contained in:
parent
cb34ca725f
commit
e3e2fd72f4
3 changed files with 25 additions and 2 deletions
|
@ -70,6 +70,7 @@ static void gameLoop() {
|
|||
++FrustrationLevel;
|
||||
|
||||
updateDiscordPresence();
|
||||
Discord_Update();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,9 @@ void Discord_Initialize(const char* applicationId, DiscordEventHandlers* handler
|
|||
void Discord_Shutdown();
|
||||
void Discord_UpdatePresence(const DiscordRichPresence* presence);
|
||||
|
||||
/* checks for incoming messages, dispatches callbacks */
|
||||
void Discord_Update();
|
||||
|
||||
/* later
|
||||
|
||||
struct DiscordChannelEventHandlers {
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
static RpcConnection* MyConnection = nullptr;
|
||||
static char ApplicationId[64]{};
|
||||
static DiscordEventHandlers Handlers{};
|
||||
static bool wasJustConnected = false;
|
||||
static bool wasJustDisconnected = false;
|
||||
|
||||
void Discord_Initialize(const char* applicationId, DiscordEventHandlers* handlers)
|
||||
{
|
||||
|
@ -18,8 +20,8 @@ void Discord_Initialize(const char* applicationId, DiscordEventHandlers* handler
|
|||
}
|
||||
|
||||
MyConnection = RpcConnection::Create();
|
||||
MyConnection->onConnect = Handlers.ready;
|
||||
MyConnection->onDisconnect = Handlers.disconnected;
|
||||
MyConnection->onConnect = []() { wasJustConnected = true; };
|
||||
MyConnection->onDisconnect = []() { wasJustDisconnected = true; };
|
||||
MyConnection->Open();
|
||||
}
|
||||
|
||||
|
@ -38,3 +40,20 @@ void Discord_UpdatePresence(const DiscordRichPresence* presence)
|
|||
frame->length = sizeof(uint32_t) + (jsonWrite - frame->message);
|
||||
MyConnection->WriteFrame(frame);
|
||||
}
|
||||
|
||||
void Discord_Update()
|
||||
{
|
||||
// check for messages
|
||||
// todo
|
||||
|
||||
// fire callbacks
|
||||
if (wasJustDisconnected && Handlers.disconnected) {
|
||||
wasJustDisconnected = false;
|
||||
Handlers.disconnected();
|
||||
}
|
||||
|
||||
if (wasJustConnected && Handlers.ready) {
|
||||
wasJustConnected = false;
|
||||
Handlers.ready();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue