Steamworks for Java

Hello all, I just found this library at github. Might be of interest for someone here.

A thin wrapper which allows Java applications to access the Steamworks C++ API. It can be easily integrated with other frameworks, such as libGDX.

11 Likes

Nice

Given the username (code-disaster), I don’t know if I can trust it :smiley:

Cool news anyway! :smile:

1 Like

That’s why it’s open source. No trust required. :wink:

5 Likes

Summoned nothing less than the author! :smile:
I didn’t mean to offend you or your work… I think it is a nice accomplishment and I might actually use it someday…

Do you know of games that uses it?

No offence taken. I’ve chosen to use this nick name a long time ago. :grin:

I list a number of use cases on the project GitHub page. I know a couple more in development. And by googling for it now and then - that’s how I found this topic as well. :smirk:

3 Likes

Hello there,

I planned to use your work @CoDi but afaik, you wrap the SteamAPI using JNI. (very nice work btw, I’tried it and it works very well !)
But regarding JNI, it is said that it breaks portability of Java ? Is it true ?

If yes, how a java game could run on linux/mac while using steamworks ?
Have I to wrap re-write the while thing with JNA instead ?

Thanks for any replies and good job again for your contrib.

Hi,

I’m not sure I understand your question. What do you mean by “breaks portability”?

JNI and JNA serve the same purpose: to interface Java with native libraries. The approaches are slightly different, though. I believe JNA can make life easier when calling rather simple native functions, but I decided to use JNI (and libGDX’ ingenious jni-gen library) because I’m more experienced with it.

Native interfaces are not “portable” because of the native code they call. You have to recompile for every platform you want to target. This is what the steamworks4j library does for you - it includes prebuilt native libraries for each of the Steamworks platform targets: Windows 32/64 bit, Linux 32/64 bit, MacOS (10.6+) shared 32+64 bit.

As a result, the library is assumed to work on every PC which meets the requirements to run Steam.

3 Likes

Thank you for your reply.

So what am I supposed to change in my code in order to use your Library for Windows or others ?
Is it automatic ?

Yes, that’s automatic. SteamAPI.init() extracts the native libraries to a folder in “java.io.tmpdir”, then choses the right libraries to load, based on the OS and architecture it runs on.

Okay that’s perfect.
Thank you so much for your work !

Hi again @CoDi ,

I did not manage to start a steam server with your API.

The function init() has arguments I do not get how to deal with.

  • ip => pass in INTEGER ?? Have I to convert the netIP in int ? or is it something different ?
  • steamPort => where can I get this info ?
  • gamePort => my used game port ? (out of steam scope)
  • queryPort => ???

Can you please give me some hints about these points ?
Did you ever try yourself to launch a SteamServer ?

No, I didn’t. The GameServer wrapper was provided by franzbischoff (Francisco Bischoff) · GitHub. I only filled some gaps, and got his feedback that he was able to use the API successfully.

The Steamworks documentation is a little tight-lipped about game servers, but as far as I know you need to do some setup beforehand, like registering a second AppID. I’m not sure if there’s an official sample AppID like the “SpaceWar!” example for testing.

The ports are described in the Steamworks SDK header files: see sdk/public/steam/steam_gameserver.h. I would assume the IP is just the IPv4 address, packed into a 32 bit value.

1 Like
// UDP port for the spacewar server to do authentication on (ie, talk to Steam on)
#define SPACEWAR_AUTHENTICATION_PORT 8766

// UDP port for the spacewar server to listen on
#define SPACEWAR_SERVER_PORT 27015

// UDP port for the master server updater to listen on
#define SPACEWAR_MASTER_SERVER_UPDATER_PORT 27016

Here are the port defined is sdk example, but no idea how they set them…

I m going to try this. Actually, Steam offers dedicated servers 'Services. And you are right in this case, a new AppID has to be requested.

I’ll go back here when it becomes more clear, as I beleive somebody else should be interested in…

Just wanted to say thanks for all of this, I will be encountering these problems soon as well and it’s a useful resource!

1 Like