diff --git a/Facepunch.Steamworks/Client/Lobby.cs b/Facepunch.Steamworks/Client/Lobby.cs index 11a83bb..bcf8afe 100644 --- a/Facepunch.Steamworks/Client/Lobby.cs +++ b/Facepunch.Steamworks/Client/Lobby.cs @@ -26,7 +26,7 @@ public enum Type : int { Private = SteamNative.LobbyType.Private, FriendsOnly = SteamNative.LobbyType.FriendsOnly, - Public = SteamNative.LobbyType.Public, + Public = SteamNative.LobbyType.Public, Invisible = SteamNative.LobbyType.Invisible, Error //happens if you try to get this when you aren't in a valid lobby } @@ -323,6 +323,17 @@ public string Name } } + /// + /// returns true if we're the current owner + /// + public bool IsOwner + { + get + { + return Owner == client.SteamId; + } + } + /// /// The Owner of the current lobby. Returns 0 if you are not in a valid lobby. /// @@ -491,6 +502,74 @@ internal void OnLobbyMemberPersonaChangeAPI( PersonaStateChange_t callback ) if ( OnLobbyMemberDataUpdated != null ) { OnLobbyMemberDataUpdated( callback.SteamID ); } } + /// + /// Sets the game server associated with the lobby. + /// This can only be set by the owner of the lobby. + /// Either the IP/Port or the Steam ID of the game server must be valid, depending on how you want the clients to be able to connect. + /// + public bool SetGameServer( System.Net.IPAddress ip, int port, ulong serverSteamId = 0 ) + { + if ( !IsValid || !IsOwner ) return false; + + var ipint = System.Net.IPAddress.NetworkToHostOrder( ip.Address ); + client.native.matchmaking.SetLobbyGameServer( CurrentLobby, (uint)ipint, (ushort)port, serverSteamId ); + return true; + } + + /// + /// Gets the details of a game server set in a lobby. + /// + public System.Net.IPAddress GameServerIp + { + get + { + uint ip; + ushort port; + CSteamID steamid; + + if ( !client.native.matchmaking.GetLobbyGameServer( CurrentLobby, out ip, out port, out steamid ) || ip == 0 ) + return null; + + return new System.Net.IPAddress( System.Net.IPAddress.HostToNetworkOrder( ip ) ); + } + } + + /// + /// Gets the details of a game server set in a lobby. + /// + public int GameServerPort + { + get + { + uint ip; + ushort port; + CSteamID steamid; + + if ( !client.native.matchmaking.GetLobbyGameServer( CurrentLobby, out ip, out port, out steamid ) ) + return 0; + + return (int)port; + } + } + + /// + /// Gets the details of a game server set in a lobby. + /// + public ulong GameServerSteamId + { + get + { + uint ip; + ushort port; + CSteamID steamid; + + if ( !client.native.matchmaking.GetLobbyGameServer( CurrentLobby, out ip, out port, out steamid ) ) + return 0; + + return steamid; + } + } + /*not implemented //set the game server of the lobby