Skip to content

Commit

Permalink
Merge pull request #269 from LossyDragon/simplify-callbacks2
Browse files Browse the repository at this point in the history
Simplify callback dispatching
  • Loading branch information
LossyDragon authored Aug 15, 2024
2 parents b3882bb + 491215c commit 8f781d1
Show file tree
Hide file tree
Showing 209 changed files with 6,824 additions and 9,141 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import in.dragonbra.javasteam.util.log.DefaultLogListener;
import in.dragonbra.javasteam.util.log.LogManager;

import java.util.Arrays;
import java.util.Base64;
import java.util.concurrent.CancellationException;

Expand Down Expand Up @@ -129,7 +130,8 @@ private void onConnected(ConnectedCallback callback) {
// parseJsonWebToken(pollResponse.accessToken, "AccessToken");
// parseJsonWebToken(pollResponse.refreshToken, "RefreshToken");
} catch (Exception e) {
System.err.println(e.getMessage());
System.err.println(Arrays.toString(e.getSuppressed()));
System.err.println("onConnected:" + e.getMessage());

// List a couple of exceptions that could be important to handle.
if (e instanceof AuthenticationException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import in.dragonbra.javasteam.enums.EPersonaState;
import in.dragonbra.javasteam.enums.EResult;
import in.dragonbra.javasteam.steam.handlers.steamfriends.Friend;
import in.dragonbra.javasteam.steam.handlers.steamfriends.PersonaState;
import in.dragonbra.javasteam.steam.handlers.steamfriends.SteamFriends;
import in.dragonbra.javasteam.steam.handlers.steamfriends.callback.FriendAddedCallback;
import in.dragonbra.javasteam.steam.handlers.steamfriends.callback.FriendsListCallback;
Expand Down Expand Up @@ -199,8 +198,6 @@ private void onPersonaStates(PersonaStatesCallback callback) {
// this callback is received when the persona state (friend information) of a friend changes

// for this sample we'll simply display the names of the friends
for (PersonaState state : callback.getPersonaStates()) {
System.out.println("State change: " + state.getName() + " " + state.getState());
}
System.out.println("State change: " + callback.getName() + " " + callback.getState());
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package `in`.dragonbra.javasteam.steam.handlers.steamapps

import `in`.dragonbra.javasteam.enums.ELicenseFlags
import `in`.dragonbra.javasteam.enums.ELicenseType
import `in`.dragonbra.javasteam.enums.EPaymentMethod
import `in`.dragonbra.javasteam.protobufs.steamclient.SteammessagesClientserver.CMsgClientLicenseList
import java.util.*

/**
* Represents a granted license (steam3 subscription) for one or more games.
*/
@Suppress("unused")
class License(license: CMsgClientLicenseList.License) {

/**
* Gets the package ID used to identify the license.
*/
val packageID: Int = license.packageId

/**
* Gets the last change number for this license.
*/
val lastChangeNumber: Int = license.changeNumber

/**
* Gets the time the license was created.
*/
val timeCreated: Date = Date(license.timeCreated * 1000L)

/**
* Gets the next process time for the license.
*/
val timeNextProcess: Date = Date(license.timeNextProcess * 1000L)

/**
* Gets the minute limit of the license.
*/
val minuteLimit: Int = license.minuteLimit

/**
* Gets the minutes used of the license.
*/
val minutesUsed: Int = license.minutesUsed

/**
* Gets the payment method used when the license was created.
*/
val paymentMethod: EPaymentMethod = EPaymentMethod.from(license.paymentMethod)

/**
* Gets the license flags.
*/
val licenseFlags: EnumSet<ELicenseFlags> = ELicenseFlags.from(license.flags)

/**
* Gets the two-letter country code where the license was purchased.
*/
val purchaseCode: String = license.purchaseCountryCode

/**
* Gets the type of the license.
*/
val licenseType: ELicenseType = ELicenseType.from(license.licenseType)

/**
* Gets the territory code of the license.
*/
val territoryCode: Int = license.territoryCode

/**
* Gets the PICS access token for this package.
*/
val accessToken: Long = license.accessToken

/**
* Gets the owner account id of the license.
*/
val ownerAccountID: Int = license.ownerId

/**
* Gets the master package id.
*/
val masterPackageID: Int = license.masterPackageId
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package `in`.dragonbra.javasteam.steam.handlers.steamapps

import `in`.dragonbra.javasteam.protobufs.steamclient.SteammessagesClientserverAppinfo.CMsgClientPICSChangesSinceResponse

/**
* Holds the change data for a single app or package
*/
@Suppress("MemberVisibilityCanBePrivate", "unused")
class PICSChangeData {

/**
* Gets the app or package ID this change data represents
*/
val id: Int

/**
* Gets the current change number of this app
*/
val changeNumber: Int

/**
* Gets signals if an access token is needed for this request
*/
val isNeedsToken: Boolean

constructor(change: CMsgClientPICSChangesSinceResponse.AppChange) {
id = change.appid
changeNumber = change.changeNumber
isNeedsToken = change.needsToken
}

constructor(change: CMsgClientPICSChangesSinceResponse.PackageChange) {
id = change.packageid
changeNumber = change.changeNumber
isNeedsToken = change.needsToken
}
}
Loading

0 comments on commit 8f781d1

Please sign in to comment.