code-disaster / steamworks4j

A thin Java wrapper to access the Steamworks API
https://code-disaster.github.io/steamworks4j/
MIT License
467 stars 64 forks source link

Added favorite game server and getter/setter for lobby the game server #46

Closed AlrikG closed 7 years ago

AlrikG commented 7 years ago

Hi, I tried to add favorite game servers and and the lobby game server features. But If I use it in java I get the following error:

java.lang.UnsatisfiedLinkError: com.codedisaster.steamworks.SteamMatchmaking.getLobbyGameServer(JJLcom/codedisaster/steamworks/SteamMatchmaking$GameServerEntry;)Z
    at com.codedisaster.steamworks.SteamMatchmaking.getLobbyGameServer(Native Method)
    at com.codedisaster.steamworks.SteamMatchmaking.getLobbyGameServer(SteamMatchmaking.java:405)

Can someone tell me what the problem is?

The main reason for this pull request is that I don't know how to connect to a game server. As far as I know a client needs to request game servers from steam. This can be achieved via steam matchmaking lobbies. After the client has found a matching lobby the server details (ip and port) are needed. So the only way I see is getLobbyGameServer(). But this method is missing. Am I on the right way?

regards Alrik

code-disaster commented 7 years ago

After the client has found a matching lobby the server details (ip and port) are needed.

I believe you misunderstand this API. GetLobbyGameServer() is just returns what has been previously set by a lobby member with SetLobbyGameServer(), which takes an IP or a gameserver SteamID.

The "favorite server" functions, from what I understand, are just a locally stored list of game servers IPs the user previously played on, and need to be added/managed by yourself too.

The Valve docs are pretty vague about all of this. As far as I understand, the server IP or SteamID must be delivered to the client / lobby by other means, and most likely involve use of the SteamGameServer and/or SteamNetworking interfaces.

The "unsatisfied link errors" happen because you probably didn't generate and compile the new/modified native code.

Anyway, thanks for the PR, I'll review and merge it as soon as possible.

AlrikG commented 7 years ago

You are right :) The "unsatisfied link errors" occurred because the native binaries were cached somehow.

It works now, but some other methods are necessary. This is how I did it:

Currently I use SetLobbyGameServer() on the lobby to set the server informations from server side. Then a client joins the lobby and gets the server informations via GetLobbyGameServer(). Now the client knows the ip address and the port.

Before connecting to the server SteamUser.initiateGameConnection() is called on client side to get the "connecting data" from the steam servers.

After connecting to the server GameServer.sendUserConnectAndAuthenticate() is called to accept the three-way-handshake.

The client is then shown in the steam server browser window :) Awesome!