steamworks4j Documentation

repository·master·Indexed 19 days ago

https://github.com/code-disaster/steamworks4j

A 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.

Tokens
930
Snippets
3
Records
6
Agent score
19%

What's inside steamworks4j

  1. Handle network packets manually

    master

    For custom network implementations, you can manually process incoming and outgoing packets using ByteBuffer objects.

    • 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);
  2. Manage user authentication and sessions

    master

    Steam Game Server provides several methods to handle user connections, authentication tickets, and session lifecycles.

    Authentication Flow:

    1. Use getAuthSessionTicket to retrieve a ticket for a user.
    2. Use beginAuthSession to start the session.
    3. Use endAuthSession to terminate the session.
    4. Use cancelAuthTicket if 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.
  3. Configure Steam Game Server settings

    master

    Use 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);
  4. Log on to Steam Game Server

    master

    To connect your server to the Steam backend, use either logOn(token) with a specific authentication token or logOnAnonymous() for anonymous access. You can check the connection status using isLoggedOn().

    // Anonymous login
    SteamGameServerNative.logOnAnonymous();
    
    // Or with a token
    SteamGameServerNative.logOn("YOUR_AUTH_TOKEN");
    
    if (SteamGameServerNative.isLoggedOn()) {
        System.out.println("Logged on! SteamID: " + SteamGameServerNative.getSteamID());
    }