koraktor / steam-condenser

A multi-language library for querying the Steam Community, Source, GoldSrc servers and Steam master servers
https://koraktor.de/steam-condenser
Other
356 stars 67 forks source link

Java - Multithreading #295

Open Khanattila opened 8 years ago

Khanattila commented 8 years ago

An example in pseudocode.

List<SteamId> steamUsers; List<SteamGame> steamGames;

steamUsers.stream().forEach((user) -> {
            try {
                steamGames.addAll(user.getGames().values());
            } catch (SteamCondenserException ex) {
                Logger.getLogger(...).log(...);
            }
});

You can not make it multithreaded? I tried different solutions but does not work.

Caused by: com.github.koraktor.steamcondenser.exceptions.SteamCondenserException: XML data could not be parsed: FWK005 parse may not be called while parsing.

koraktor commented 8 years ago

Steam Condenser’s Java implementation uses a static DocumentBuilder instance which is reused for all XML parsing. That prevents it from being capable of multi-threading.

Initially, XMLData should be removed in version 2.0.0 as Valve deprecated its XML APIs. As there‘s still no full-featured Web API, this might change, though. So I might consider this.

However, the master branch already uses the Web API for most parts, e.g. SteamId#getGames(). So you might have more luck with that branch.