Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the need for kotlin stdlib dependency #258

Merged
merged 3 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ plugins {

allprojects {
group = "in.dragonbra"
version = "1.4.0-SNAPSHOT"
version = "1.4.0"
}

repositories {
Expand Down
4 changes: 1 addition & 3 deletions javasteam-samples/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
alias(libs.plugins.kotlin.jvm)
`java-library`
}

repositories {
Expand All @@ -19,6 +19,4 @@ dependencies {
implementation(libs.kotlin.coroutines)
implementation(libs.protobuf.java) // To access protobufs directly as shown in Sample #2
implementation(libs.qrCode)

testImplementation(libs.test.jupiter.api)
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ private void onConnected(ConnectedCallback callback) {

CredentialsAuthSession authSession = auth.beginAuthSessionViaCredentials(authDetails);

// AuthPollResult pollResponse = authSession.pollingWaitForResult(); // This method is for Kotlin (coroutines)
AuthPollResult pollResponse = authSession.pollingWaitForResultCompat();
// Note: This is blocking, it would be up to you to make it non-blocking for Java.
// Note: Kotlin uses should use ".pollingWaitForResult()" as its a suspending function.
AuthPollResult pollResponse = authSession.pollingWaitForResultCompat().get();

LogOnDetails details = new LogOnDetails();
details.setUsername(pollResponse.getAccountName());
Expand All @@ -132,11 +133,11 @@ private void onConnected(ConnectedCallback callback) {

// List a couple of exceptions that could be important to handle.
if (e instanceof AuthenticationException) {
System.out.println("An Authentication error has occurred.");
System.out.println("An Authentication error has occurred. " + e.getMessage());
}

if (e instanceof CancellationException) {
System.out.println("An Cancellation exception was raised. Usually means a timeout occurred");
System.out.println("An Cancellation exception was raised. Usually means a timeout occurred. " + e.getMessage());
}
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import in.dragonbra.javasteam.steam.authentication.AuthenticationException;
import in.dragonbra.javasteam.steam.authentication.AuthPollResult;
import in.dragonbra.javasteam.steam.authentication.AuthSessionDetails;
import in.dragonbra.javasteam.steam.authentication.OnChallengeUrlChanged;
import in.dragonbra.javasteam.steam.authentication.IChallengeUrlChanged;
import in.dragonbra.javasteam.steam.authentication.QrAuthSession;
import in.dragonbra.javasteam.steam.authentication.SteamAuthentication;
import in.dragonbra.javasteam.steam.handlers.steamunifiedmessages.SteamUnifiedMessages;
Expand All @@ -18,7 +18,6 @@
import in.dragonbra.javasteam.steam.steamclient.callbacks.DisconnectedCallback;
import in.dragonbra.javasteam.util.log.DefaultLogListener;
import in.dragonbra.javasteam.util.log.LogManager;
import org.jetbrains.annotations.NotNull;
import pro.leaco.console.qrcode.ConsoleQrcode;

import java.util.concurrent.CancellationException;
Expand All @@ -32,7 +31,7 @@
* @since 2023-03-19
*/
@SuppressWarnings("FieldCanBeLocal")
public class SampleLogonQRAuthentication implements Runnable, OnChallengeUrlChanged {
public class SampleLogonQRAuthentication implements Runnable, IChallengeUrlChanged {

private SteamClient steamClient;

Expand Down Expand Up @@ -109,8 +108,9 @@ private void onConnected(ConnectedCallback callback) {

// Starting polling Steam for authentication response
// This response is later used to log on to Steam after connecting
// AuthPollResult pollResponse = authSession.pollingWaitForResult(); // This method is for Kotlin (coroutines)
AuthPollResult pollResponse = authSession.pollingWaitForResultCompat();
// Note: This is blocking, it would be up to you to make it non-blocking for Java.
// Note: Kotlin uses should use ".pollingWaitForResult()" as its a suspending function.
AuthPollResult pollResponse = authSession.pollingWaitForResultCompat().get();

System.out.println("Connected to Steam! Logging in " + pollResponse.getAccountName() + "...");

Expand All @@ -127,12 +127,14 @@ private void onConnected(ConnectedCallback callback) {
System.err.println(e.getMessage());

if (e instanceof AuthenticationException) {
System.out.println("An Authentication error has occurred.");
System.out.println("An Authentication error has occurred. " + e.getMessage());
}

if (e instanceof CancellationException) {
System.out.println("An Cancellation exception was raised. Usually means a timeout occurred");
System.out.println("An Cancellation exception was raised. Usually means a timeout occurred. " + e.getMessage());
}

steamUser.logOff();
}
}

Expand Down Expand Up @@ -175,7 +177,7 @@ private void drawQRCode(QrAuthSession authSession) {
}

@Override
public void onChanged(@NotNull QrAuthSession qrAuthSession) {
public void onChanged(QrAuthSession qrAuthSession) {
drawQRCode(qrAuthSession);
}
}
Loading
Loading