SteamGameServerAPI

Swift
public final class SteamGameServerAPI: SteamBaseAPI, Sendable

An instance of the Steamworks game server API

Create and retain one of these to access and use the Steamworks game server APIs.

Steamworks ref: steam_gameserver.h


Topics

Lifecycle

init?(ip: Int, port: UInt16, queryPort: UInt16?, serverMode: ServerMode, version: String)

Initialize the Steamworks game server API.

The game server API is shut down when this object goes out of scope. See SteamGameServer_Init().

Declaration
Swift
public init?(
    ip: Int = 0, port: UInt16, queryPort: UInt16? = nil, serverMode: ServerMode,
    version: String)
Parameters
ip

IPv4 address to bind. Default is 0, INADDR_ANY.

port

Port clients connect to for gameplay.

queryPort

Port clients use for browser etc. Default of nil means STEAMGAMESERVER_QUERY_PORT_SHARED, see docs.

serverMode

Authentication mode.

version

Server version.

Return Value

nil if the API failed to initialize.

Interfaces

var gameServer: SteamGameServer

Access the Steamworks ISteamGameServer interface

Declaration
Swift
public let gameServer: SteamGameServer

var gameServerStats: SteamGameServerStats

Access the Steamworks ISteamGameServerStats interface

Declaration
Swift
public let gameServerStats: SteamGameServerStats