mirror of
https://git.suyu.dev/suyu/discord-rpc.git
synced 2025-12-23 15:55:06 +01:00
Allow for disconnect/reconnect.
This commit is contained in:
parent
54bef63d67
commit
0271889b2e
3 changed files with 35 additions and 9 deletions
|
|
@ -75,6 +75,18 @@ static int prompt(char* line, size_t size)
|
|||
return res;
|
||||
}
|
||||
|
||||
static void discordInit()
|
||||
{
|
||||
DiscordEventHandlers handlers;
|
||||
memset(&handlers, 0, sizeof(handlers));
|
||||
handlers.ready = handleDiscordReady;
|
||||
handlers.disconnected = handleDiscordDisconnected;
|
||||
handlers.errored = handleDiscordError;
|
||||
handlers.joinGame = handleDiscordJoin;
|
||||
handlers.spectateGame = handleDiscordSpectate;
|
||||
Discord_Initialize(APPLICATION_ID, &handlers, 1);
|
||||
}
|
||||
|
||||
static void gameLoop()
|
||||
{
|
||||
char line[512];
|
||||
|
|
@ -88,6 +100,19 @@ static void gameLoop()
|
|||
if (line[0] == 'q') {
|
||||
break;
|
||||
}
|
||||
|
||||
if (line[0] == 't') {
|
||||
printf("Shutting off Discord.\n");
|
||||
Discord_Shutdown();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (line[0] == 'y') {
|
||||
printf("Reinit Discord.\n");
|
||||
discordInit();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (time(NULL) & 1) {
|
||||
printf("I don't understand that.\n");
|
||||
}
|
||||
|
|
@ -113,15 +138,7 @@ static void gameLoop()
|
|||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
DiscordEventHandlers handlers;
|
||||
memset(&handlers, 0, sizeof(handlers));
|
||||
handlers.ready = handleDiscordReady;
|
||||
handlers.disconnected = handleDiscordDisconnected;
|
||||
handlers.errored = handleDiscordError;
|
||||
handlers.joinGame = handleDiscordJoin;
|
||||
handlers.spectateGame = handleDiscordSpectate;
|
||||
|
||||
Discord_Initialize(APPLICATION_ID, &handlers, 1);
|
||||
discordInit();
|
||||
|
||||
gameLoop();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue