Skip to content

Commit

Permalink
feat: test class
Browse files Browse the repository at this point in the history
  • Loading branch information
Fatonndev committed Dec 4, 2022
1 parent c84967b commit 4082503
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/main/java/ru/obvilion/discordrpc/DiscordRPC.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,6 @@ private void startReading() {
Event event = Event.of(json.optString("evt", null));
String nonce = json.optString("nonce", null);

System.out.println(json.toString());

// Получаем ответ на последнюю команду от RPC
switch (event) {
// ОК
Expand Down
50 changes: 50 additions & 0 deletions src/test/java/RPCTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import ru.obvilion.discordrpc.DiscordRPC;
import ru.obvilion.discordrpc.DiscordRPCListener;
import ru.obvilion.discordrpc.api.RichPresence;
import ru.obvilion.discordrpc.api.User;
import ru.obvilion.discordrpc.exceptions.NoDiscordException;
import ru.obvilion.json.JSONObject;

import java.time.OffsetDateTime;

public class RPCTest {
public static void main(String[] args) throws NoDiscordException {
DiscordRPC rpc = new DiscordRPC("657878741703327754");

rpc.setListener(new DiscordRPCListener() {
public void onActivityJoin(DiscordRPC client, String secret) {
System.out.println("RPC Join - " + secret);
}

public void onActivitySpectate(DiscordRPC client, String secret) {
System.out.println("RPC Spectate - " + secret);
}

public void onActivityJoinRequest(DiscordRPC client, String secret, User user) {
System.out.println("RPC Join request - " + secret + ", " + user);
}

public void onReady(DiscordRPC client) {
System.out.println("RPC Ready");
}

public void onClose(DiscordRPC client, JSONObject json) {
System.out.println("RPC Closed");
}

public void onDisconnect(DiscordRPC client, Throwable t) {
System.out.println("RPC Disconnected");
}
});

rpc.connect();

rpc.sendRichPresence(
new RichPresence.Builder()
.setDetails("Hello,")
.setState("Discord RPC!")
.setStartTimestamp(OffsetDateTime.now())
.build()
);
}
}

0 comments on commit 4082503

Please sign in to comment.