I have implemented SteamWorks into our UNET-based project.
As a host, I
create Steam Lobby using SteamMatchmaking, and after that
SteamGameServer using GS_AUTH_API. After server is started, I
update lobby custom data with SteamGameServer.GetPublicIP(), so the server public IP address is stored in the lobby
On the UNET side, I start server (register handlers, then configure with topology and then NetworkServer.Listen(SERVER_PORT)).
As a client, I
receive Lobby list and get server public ip from that lobby
create NetworkClient and call Connect with IPEndPoint created from the server IP address and port that I got from lobby
However, the UNET-side does not seem to be working. After client tries to connect, nothing happens and no messages are sent.
Has anyone here successfully connected Steam with HLAPI (UNET)? Is this right way to connect NetworkClient via Steam? There does not seem to be any tutorials on this and all I got are UNET source code and steamworks documentation :).
Ok so I managed to get it working, although I’m not very happy how its done:
From investigation I did on UNET, it’s not that simple to attach to Steam including their P2P NAT layer. The problem is, when someone want to use Steam NAT or Relay servers, he need to use their packet sending/receiving API. I have found that I can override NetworkConnection TransportSend function, but receive code is in NetworkClient so I would need to override also that. I haven’t found a simple way to hook on UNET packet sending/receiving to replace it with SteamGameServerNetworking.
Instead of that I went by detour: We have bought the NAT Traversal plugin. When starting online host, I create Steam Lobby. After NAT Traversal plugin is connected to facilitator, I update Lobby data with host guid and internal/external IPs.
When someone wants to connect, he get these data from lobby and connect to other player using NAT plugin. So Steam is only used for lobbies (or other stuff like achievements, friends, …). Communication is done by that plugin.
I’m not happy with this because it is not clean Steam integration. It requires 2 third party plugins to get it working. Maybe someday UNET will support Steam directly…