Skip to content

Commit

Permalink
Discord RPC improvements and minor client change
Browse files Browse the repository at this point in the history
  • Loading branch information
Jo0001 committed Nov 19, 2020
1 parent 2ac3313 commit 98bd721
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 24 deletions.
37 changes: 18 additions & 19 deletions src/de/jo0001/gloomhaven/battleGoalCards/core/Main.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.jo0001.gloomhaven.battleGoalCards.core;

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Cursor;
Expand All @@ -9,6 +10,7 @@
import javafx.stage.Stage;
import net.arikia.dev.drpc.DiscordEventHandlers;
import net.arikia.dev.drpc.DiscordRPC;
import net.arikia.dev.drpc.DiscordRichPresence;

import java.util.Date;

Expand All @@ -35,30 +37,27 @@ public void start(Stage primaryStage) throws Exception {
DiscordRPC.discordShutdown();
}));

initDiscord();
new Thread(() -> {
DiscordEventHandlers handlers = new DiscordEventHandlers.Builder().setReadyEventHandler((user) -> {
Main.ready = true;
System.out.println("Welcome " + user.username + "#" + user.discriminator);
DiscordRichPresence.Builder presence = new DiscordRichPresence.Builder("");
Date date = new Date();
long timeMilli = date.getTime();
presence.setStartTimestamps(timeMilli);
presence.setBigImage("logo", "");
DiscordRPC.discordUpdatePresence(presence.build());
}).build();
DiscordRPC.discordInitialize("710170554543374377", handlers, false);
do {
DiscordRPC.discordRunCallbacks();
} while (!ready);
}).start();
primaryStage.show();
System.out.println("Running callbacks...");
do {
DiscordRPC.discordRunCallbacks();
} while (!ready);
}

@Override
public void stop() {
System.exit(0);
}

private static void initDiscord() {
DiscordEventHandlers handlers = new DiscordEventHandlers.Builder().setReadyEventHandler((user) -> {
Main.ready = true;
System.out.println("Welcome " + user.username + "#" + user.discriminator + ".");
net.arikia.dev.drpc.DiscordRichPresence.Builder presence = new net.arikia.dev.drpc.DiscordRichPresence.Builder("");
Date date = new Date();
long timeMilli = date.getTime();
presence.setStartTimestamps(timeMilli);
presence.setBigImage("logo", "");
DiscordRPC.discordUpdatePresence(presence.build());
}).build();
DiscordRPC.discordInitialize("710170554543374377", handlers, false);
}
}
10 changes: 5 additions & 5 deletions src/de/jo0001/gloomhaven/battleGoalCards/network/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public class Client extends Thread {
private boolean filled = false;
private Socket client;

private String host;
private int port;
private Controller controller;
private final String host;
private final int port;
private final Controller controller;

public Client(String host, int port, Controller controller) {
this.host = host;
Expand Down Expand Up @@ -113,11 +113,11 @@ public void getInfo() {
DataOutputStream output = new DataOutputStream(client.getOutputStream());
System.out.println("OutputStream ready");
output.writeUTF("getnumber");
output.flush();
System.out.println("Send number request done");
} catch (IOException e) {
e.printStackTrace();
}
}


}
}

0 comments on commit 98bd721

Please sign in to comment.