steamworks4j Documentation
repository·master·Indexed 19 days ago
https://github.com/code-disaster/steamworks4jA thin Java wrapper for the Steamworks C++ API that allows Java developers to integrate Steam features into their applications. Includes functionality for Steam Game Server configuration, user authentication and session management, and manual network packet handling via ByteBuffer.
What's inside steamworks4j
- steamworks4j is a thin wrapper that enables Java applications to access the Steamworks C++ API. It allows developers to integrate Steam features into Java-based games and applications.
Access steamworks4j documentation and showcase
masterFor detailed API references, usage guides, and a list of games utilizing the library, visit the official documentation sites:
- Full Documentation: http://code-disaster.github.io/steamworks4j/
- Games Showcase: http://code-disaster.github.io/steamworks4j/showcase.html
Handle network packets manually
masterFor custom network implementations, you can manually process incoming and outgoing packets using
ByteBufferobjects.handleIncomingPacket(data, offset, size, srcIP, srcPort): Processes a packet received from a specific IP and port.getNextOutgoingPacket(out, offset, size, netAdr, port): Retrieves the next packet that needs to be sent to a specific address and port.
// Example of handling an incoming packet ByteBuffer buffer = ByteBuffer.allocate(1024); // ... fill buffer with data ... boolean handled = SteamGameServerNative.handleIncomingPacket(buffer, 0, buffer.position(), clientIP, clientPort);Manage user authentication and sessions
masterSteam Game Server provides several methods to handle user connections, authentication tickets, and session lifecycles.
Authentication Flow:
- Use
getAuthSessionTicketto retrieve a ticket for a user. - Use
beginAuthSessionto start the session. - Use
endAuthSessionto terminate the session. - Use
cancelAuthTicketif a ticket is no longer needed.
User Verification:
userHasLicenseForApp(steamID, appID): Checks if a specific user owns a specific application.updateUserData(steamIDUser, playerName, score): Updates the user's name and score on the server.
- Use
Configure Steam Game Server settings
masterUse the following methods to configure the identity and metadata of your Steam Game Server before logging on. These settings define how the server appears in the Steam server browser and its operational mode.
// Example configuration sequence SteamGameServerNative.setProduct("MY_PRODUCT_ID"); SteamGameServerNative.setGameDescription("My Awesome Game Server"); SteamGameServerNative.setServerName("Official Server #1"); SteamGameServerNative.setMapName("de_dust2"); SteamGameServerNative.setMaxPlayerCount(32); SteamGameServerNative.setDedicatedServer(true);Log on to Steam Game Server
masterTo connect your server to the Steam backend, use either
logOn(token)with a specific authentication token orlogOnAnonymous()for anonymous access. You can check the connection status usingisLoggedOn().// Anonymous login SteamGameServerNative.logOnAnonymous(); // Or with a token SteamGameServerNative.logOn("YOUR_AUTH_TOKEN"); if (SteamGameServerNative.isLoggedOn()) { System.out.println("Logged on! SteamID: " + SteamGameServerNative.getSteamID()); }