Steamworks dokumentáció
steam_gameserver.h
Provides the core foundation to initialize and access the Steamworks GameServer API.

Functions


These are global functions which do not require an interface to set up. You can read more about these functions in Steamworks API Overview - Steam Game Servers.

SteamGameServer_Init

inline bool SteamGameServer_Init( uint32 unIP, uint16 usSteamPort, uint16 usGamePort, uint16 usQueryPort, EServerMode eServerMode, const char *pchVersionString );
NameTypeDescription
unIPuint32The IP address you are going to bind to. (This should be in host order, i.e 127.0.0.1 == 0x7f000001). You can use INADDR_ANY to bind to all local IPv4 addresses.
usSteamPortuint16The local port used to communicate with the steam servers.
usGamePortuint16The port that clients will connect to for gameplay.
usQueryPortuint16The port that will manage server browser related duties and info pings from clients.
eServerModeEServerModeSets the authentication method of the server.
pchVersionStringconst char *The version string is usually in the form x.x.x.x, and is used by the master server to detect when the server is out of date. (Only servers with the latest version will be listed.)

Initializes the ISteamGameServer interface object, and set server properties which may not be changed.

After calling this function, you should set any additional server parameters, and then call ISteamGameServer::LogOnAnonymous or ISteamGameServer::LogOn.

If you pass in MASTERSERVERUPDATERPORT_USEGAMESOCKETSHARE into usQueryPort, then the game server will use GameSocketShare mode, which means that the game is responsible for sending and receiving UDP packets for the master server updater.

Returns: bool


See Also: SteamAPI_Init

SteamGameServer_ReleaseCurrentThreadMemory

inline void SteamGameServer_ReleaseCurrentThreadMemory();
Frees the internal Steamworks API memory associated with the calling thread.

Most Steamworks API functions allocate a small amount of thread-local memory for parameter storage, calling this will manually free such memory. This function is called automatically by SteamGameServer_RunCallbacks, so a program that only ever accesses the Steamworks API from a single thread never needs to explicitly call this function.

See Also: SteamAPI_ReleaseCurrentThreadMemory

SteamGameServer_RunCallbacks

S_API void SteamGameServer_RunCallbacks();
Dispatches callbacks created with STEAM_GAMESERVER_CALLBACK and call results to all of the registered listeners.

It's best to call this at >10Hz, the more time between calls, the more potential latency between receiving events or results from the Steamworks API.
Most games call this once per render-frame. All registered listener functions will be invoked during this call, in the callers thread context.

SteamGameServer_RunCallbacks is safe to call from multiple threads simultaneously, but if you choose to do this, callback code could be executed on any thread. One alternative is to call SteamGameServer_RunCallbacks from the main thread only, and call SteamGameServer_ReleaseCurrentThreadMemory regularly on other threads.

See Also: SteamGameServer_RunCallbacks

SteamGameServer_Shutdown

S_API void SteamGameServer_Shutdown();
Shuts down the Steamworks GameServer API, releases pointers and frees memory.

See Also: SteamAPI_Shutdown

Enums

These are enums which are defined for use with steam_gameserver.

EServerMode

Used to set the authentication and VAC status of a game server when initializing with SteamGameServer_Init.

NameValueDescription
eServerModeInvalid0DEPRECATED - DO NOT USE!
eServerModeNoAuthentication1Don't authenticate user logins and don't list on the server list.
eServerModeAuthentication2Authenticate users, list on the server list, don't run VAC on clients that connect.
eServerModeAuthenticationAndSecure3Authenticate users, list on the server list and VAC protect clients.