Skip to content

Commit

Permalink
DiscordRPC - Connection resiliency fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Inrixia committed Jun 25, 2024
1 parent 10c6e0f commit 17875b8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions plugins/DiscordRPC/src/DiscordRPC.native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ export class DiscordRPC {
// @ts-expect-error Types dont include internals like transport
return !!this.rpcClient?.transport?.socket;
}
async ensureRPC() {
if (this.isConnected()) return this.rpcClient!;
return (this.rpcClient = await new Client({ transport: "ipc" }).login({ clientId: this.clientId }));
async ensureRPC(): Promise<Client> {
if (this.rpcClient && this.isConnected()) return this.rpcClient;
this.rpcClient = await new Client({ transport: "ipc" }).login({ clientId: this.clientId });
if (!this.isConnected()) return this.ensureRPC();
return this.rpcClient;
}
async cleanp(clearActivity?: false) {
if (this.isConnected() && clearActivity) await this.rpcClient!.clearActivity().catch(onCleanupErr);
Expand Down

0 comments on commit 17875b8

Please sign in to comment.