This repository has been archived by the owner on Aug 15, 2022. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Integrating Steamworks.NET to make use of Steams Peer2Peer networking, Lobby systems, and matchmaking systems. With Steam's matchmaking:
In order to connect to a user all we need is their Steam ID or the ID to the lobby they are hosting.
public void ConnectToLobby(CSteamID lobbyId)
{
SteamP2PClient client = new SteamP2PClient();
client.Connect(lobbyId);
networkManager.Initialize(client );
}
Hosting a lobby requires your Steam ID, the type of lobby you want to create, and optionally a delegate for further actions (like updating lobby metadata) once it has been registered.
public void HostNewLobby(bool isPrivate)
{
SteamP2PServer myLobby = new SteamP2PServer(5); //Max connections
myLobby.Host(SteamManager.Me, isPrivate ? ELobbyType.k_ELobbyTypeFriendsOnly : ELobbyType.k_ELobbyTypePublic);
}
A list of active lobbies can be retrieved via
SteamMatchmaking:RequestLobbyList()
UDP classes have been cloned and modified to their SteamP2P variants.
UDP still left intact as SteamP2P is merely an alternative for Steam applications and not a replacement of current implementations.
This is tested and working for up to 2 players. I have been having issues with 3 or more devices being connected (Mainly with NetworkBehaviors and NetworkObjects not being paired correctly).
See the following:
https://github.com/rlabrecque/Steamworks.NET
https://partner.steamgames.com/doc/api/ISteamMatchmaking#functions
https://partner.steamgames.com/doc/api/ISteamNetworking#functions