Skip to content

Steam Networking Sockets - Basic Implementation#138

Closed
tylerhasman wants to merge 9 commits intocode-disaster:masterfrom
tylerhasman:master
Closed

Steam Networking Sockets - Basic Implementation#138
tylerhasman wants to merge 9 commits intocode-disaster:masterfrom
tylerhasman:master

Conversation

@tylerhasman
Copy link
Copy Markdown

@tylerhasman tylerhasman commented Jan 30, 2024

Implements steam networking sockets.

Closed in lieu of #150 which improves on this.

@Osaris31
Copy link
Copy Markdown

Osaris31 commented Sep 13, 2024

@tylerhasman there is a typo in this function:

public int receiveMessagesOnPollGroup(int pollGroupHandle, SteamNetworkingMessage[] messages){
     return SteamNetworkingSocketsNative.receiveMessagesOnConnection(pollGroupHandle, messages, messages.length);
}

Should be:
return SteamNetworkingSocketsNative.receiveMessagesOnPollGroup(pollGroupHandle, messages, messages.length);

Otherwise this works but I'm a bit concerned about performance and memory seeing that creation of
jbyteArray javaByteArray = env->NewByteArray(netMessage->m_cbSize);
for each message, instead of somehow re-using a buffer.

Also, sendMessageToConnection could come with a way to have an offset for its buffer, like sendP2PPacket does.

Anyway, thanks a lot for your work!

@tylerhasman
Copy link
Copy Markdown
Author

@tylerhasman there is a typo in this function:

public int receiveMessagesOnPollGroup(int pollGroupHandle, SteamNetworkingMessage[] messages){
     return SteamNetworkingSocketsNative.receiveMessagesOnConnection(pollGroupHandle, messages, messages.length);
}

Should be: return SteamNetworkingSocketsNative.receiveMessagesOnPollGroup(pollGroupHandle, messages, messages.length);

Otherwise this works but I'm a bit concerned about performance and memory seeing that creation of jbyteArray javaByteArray = env->NewByteArray(netMessage->m_cbSize); for each message, instead of somehow re-using a buffer.

Also, sendMessageToConnection could come with a way to have an offset for its buffer, like sendP2PPacket does.

Anyway, thanks a lot for your work!

Oh shoot that would explain why poll groups weren't working. Thank you I will update this.

@mmm1245
Copy link
Copy Markdown

mmm1245 commented Jul 24, 2025

Will this get merged anytime soon? Don't know how ready it is, but having this api implemented would help out a lot with my game.

@Lanse0123
Copy link
Copy Markdown

this would be extremely useful if it was part of steamworks4j, is this like close to working or like ready to use? Otherwise I might just add this to my own part of the game and pray lol

@tylerhasman
Copy link
Copy Markdown
Author

this would be extremely useful if it was part of steamworks4j, is this like close to working or like ready to use? Otherwise I might just add this to my own part of the game and pray lol

It seems like the repo author is MIA. I could fork it and put it into my own branch

@tylerhasman
Copy link
Copy Markdown
Author

@Lanse0123
Copy link
Copy Markdown

@tylerhasman hey thank you so much! We are actually using your fork for the steamwork wrapper for our game! Things are almost working, but we are having some weird errors with sockets and just trying to connect to steam's relay servers and etc. James and I might have questions about it if your cool with helping! Also remind me to upvote your fork / branch, idk how to on github but I definitely will at some point because it has been very useful!

@tylerhasman
Copy link
Copy Markdown
Author

@tylerhasman hey thank you so much! We are actually using your fork for the steamwork wrapper for our game! Things are almost working, but we are having some weird errors with sockets and just trying to connect to steam's relay servers and etc. James and I might have questions about it if your cool with helping! Also remind me to upvote your fork / branch, idk how to on github but I definitely will at some point because it has been very useful!

Happy to help! You can add me on discord @tyler

@Lanse0123
Copy link
Copy Markdown

Hi! I tried adding you on discord @tylerhasman though it says you arent accepting friend requests. My username is @lanse012 if you want to add me, but I think I might be good. I really thank you for adding the socket support, and from it our multiplayer game is now pretty much working! If you would like me to show you or something I would be cool with that!

@AnthonyRuffino
Copy link
Copy Markdown

Hi! I tried adding you on discord @tylerhasman though it says you arent accepting friend requests. My username is @lanse012 if you want to add me, but I think I might be good. I really thank you for adding the socket support, and from it our multiplayer game is now pretty much working! If you would like me to show you or something I would be cool with that!

I wanna see it. Link to a clip of your game or show off some code. I'm interested. I am considering using this fork if it really supports networking.

@Lanse0123
Copy link
Copy Markdown

@tylerhasman https://www.youtube.com/watch?v=IoajE4BVZL8
Thats the trailer, if you want to play it then join my Discord, I can give you beta access to it
https://discord.gg/qsbJrBdw5V

I could show code but idk if I want to put it here, this reply thread is getting long and it takes forever to talk across this

@AnthonyRuffino
Copy link
Copy Markdown

AnthonyRuffino commented Nov 24, 2025

https://www.youtube.com/watch?v=IoajE4BVZL8 Thats the trailer, if you want to play it then join my Discord, I can give you beta access to it https://discord.gg/qsbJrBdw5V

I could show code but idk if I want to put it here, this reply thread is getting long and it takes forever to talk across this

@Lanse0123 That was mind-blowing.

I took a branch of this repo and merged it with another fork which had some networking support: https://github.com/twopology/steamnetworks4j

But I have not actually built the Windows of MacOS natives yet. I will build the Windows ones and make a new release if you are interested. I have fully tested the P2P networking with Linux and it is working in my game right now.

I made the artifacts available with github packages so you can include them in your project like:

  1. Maven (pom.xml) + JitPack
<repositories>
    <repository>
        <id>jitpack</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>com.github.code-disaster</groupId>
        <artifactId>steamworks4j</artifactId>
        <version>1.9.0</version>
    </dependency>
</dependencies>
  1. Maven (pom.xml) + GitHub Packages
<repositories>
    <repository>
        <id>github</id>
        <url>https://maven.pkg.github.com/twopology/steamnetworks4j</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>org.twopology</groupId>
        <artifactId>steamworks4j</artifactId>
        <version>1.9.0</version>
    </dependency>
</dependencies>

Note: Requires authentication in ~/.m2/settings.xml:

<servers>
    <server>
        <id>github</id>
        <username>YOUR_GITHUB_USERNAME</username>
        <password>YOUR_GITHUB_TOKEN</password>
    </server>
</servers>
3. Gradle (build.gradle) + JitPack
repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'com.github.code-disaster:steamworks4j:1.9.0'
}
  1. Gradle (build.gradle) + GitHub Packages
repositories {
    maven {
        name = "GitHubPackages"
        url = "https://maven.pkg.github.com/twopology/steamnetworks4j"
        credentials {
            username = project.findProperty("githubUsername") ?: System.getenv("GITHUB_USERNAME")
            password = project.findProperty("githubToken") ?: System.getenv("GITHUB_TOKEN")
        }
    }
}

dependencies {
    implementation 'org.twopology:steamworks4j:1.9.0'
}

The key differences:

JitPack: Uses com.github.code-disaster groupId, no auth needed
GitHub Packages: Uses org.twopology groupId, requires GitHub token authentication

@tylerhasman
Copy link
Copy Markdown
Author

Closing this in lieu of the work done by @casid in #150 thanks for improving on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants