PlayFab / LocalMultiplayerAgent

An executable that mimics PlayFab Multiplayer (Thunderhead) operations to aid in local debugging.
https://docs.microsoft.com/en-us/gaming/playfab/features/multiplayer/servers/thunderhead
22 stars 6 forks source link

Does not work with Java Jars #2

Open tylerhasman opened 5 years ago

tylerhasman commented 5 years ago

My server is written in Java and I want to launch it like so: "StartGameCommand": "C:/Assets/jre/bin/java.exe -jar C:/Assets/gameserver.jar",

However, the second C:/Assets/ does not get replaced by the proper folder and as such, does not launch the jar file.

tylerhasman commented 5 years ago

So I managed to get it to work by launching the jar from my computer with an absolute path as so: "StartGameCommand": "C:/Assets/jre/bin/java.exe -jar C:/Users/user/Documents/GitHub/WizardGame/out/artifacts/gameserver_jar/gameserver.jar",

Then I ran into another road block. There is a bug with the Java SDK for the game server. You need to initialize the "Build Metadata" in "JsonFileConfiguration", otherwise it throws a NPE. I detected it in the game server by loading in the config file, checking if its null, then setting it to an initialized value and resaving the file to the disc.

        JsonFileConfiguration jsonFileConfiguration = new JsonFileConfiguration();

        if(jsonFileConfiguration.getBuildMetadata() == null){
            logger.warn("Detected build metadata is null!");
            jsonFileConfiguration.setBuildMetadata(new HashMap<>());
            jsonFileConfiguration.save();
            logger.warn("Saved new json stuff");
        }
ravarnamsft commented 5 years ago

@tylerhasman , thanks for reporting these issues. We will take a look and fix them and report back here.

ravarnamsft commented 5 years ago

@tylerhasman , I can see how the arguments were not converted properly when running outside of the container, but did you see the same issue while running it within a container as well?

Regarding the JsonFileConfiguration, were you trying to access the buildMetadata (when it was null) or are you suggesting that the serialization itself fails if the buildMetadata is null? I don't get the "Save" part above, did you update the file directly?

tylerhasman commented 5 years ago

Yes I had to overwrite the file with valid data

dgkanatsios commented 5 years ago

hi @tylerhasman, any further questions/help needed towards this issue? If not, we can close it.

tylerhasman commented 5 years ago

I don't believe the issue has actually been fixed. I had to use essentially java reflection to fix it.

dgkanatsios commented 5 years ago

thanks for mentioning that, will keep the issue open. Can you share your workaround so other users can potentially benefit while we're working on the fix?