Game Server
Only available in the GodotSteam Server branches
Functions
associateWithClan
associateWithClan( uint64_t
clan_id )
Parameter | Type | Notes |
---|---|---|
clan_id | uint64_t | The Steam ID of the group you want to be associated with. |
Associate this game server with this clan for the purposes of computing player compatibility.
Returns: void
Triggers
associate_clan callback
beginAuthSession
beginAuthSession( PackedByteArray
auth_ticket, uint64_t
steam_id )
Parameter | Type | Notes |
---|---|---|
auth_ticket | PackedByteArray | The auth ticket to validate. |
steam_id | uint64_t | The entity's Steam ID that sent this ticket. |
Authenticate the ticket from the entity Steam ID to be sure it is valid and isn't reused.
The ticket is created on the entity with getAuthSessionTicket and then needs to be provided over the network for the other end to validate. This registers for validate_auth_ticket_response callbacks if the entity goes offline or cancels the ticket. See EAuthSessionResponse for more information.
When the multiplayer session terminates you must call endAuthSession.
Returns: BeginAuthSessionResult enum
cancelAuthTicket
cancelAuthTicket( uint32_t
auth_ticket )
Parameter | Type | Notes |
---|---|---|
auth_ticket_handle | uint32_t | The active auth ticket to cancel. |
Cancel auth ticket from getAuthSessionTicket; called when no longer playing game with the entity you gave the ticket to.
Returns: void
clearAllKeyValues
clearAllKeyValues( )
Call this to clear the whole list of key / values that are sent in rule queries.
Returns: void
computeNewPlayerCompatibility
computeNewPlayerCompatibility( uint64_t
steam_id )
Parameter | Type | Notes |
---|---|---|
steam_id | uint64_t | The Steam ID of the player that is attempting to join. |
Checks if any of the current players don't want to play with this new player that is attempting to join or vice versa; based on the frenemy system.
Returns: void
Triggers
player_compat callback
createUnauthenticatedUserConnection
createUnauthenticatedUserConnection( )
Creates a fake user (ie, a bot) which will be listed as playing on the server, but skips validation.
Returns: uint64_t
Returns a SteamID for the user to be tracked with, you should call endAuthSession when this user leaves the server just like you would for a real user.
Notes
This is part of the old user authentication API and should not be mixed with the new API.
endAuthSession
endAuthSession( uint64_t
steam_id )
Parameter | Type | Notes |
---|---|---|
steam_id | uint64_t | The entity to end the active auth session with. |
Stop tracking started by beginAuthSession; called when no longer playing game with this entity.
Returns: void
getAuthSessionTicket
getAuthSessionTicket( )
Retrieve a authentication ticket to be sent to the entity who wishes to authenticate you. After calling this you can send the ticket to the entity where they can then call beginAuthSession to verify this entities integrity.
When creating a ticket for use by the ISteamUserAuth/AuthenticateUserTicket Web API, the calling application should wait for the get_auth_session_ticket_response callback generated by the API call before attempting to use the ticket to ensure that the ticket has been communicated to the server.
If this callback does not come in a timely fashion (10 - 20 seconds), then your client is not connected to Steam, and the authenticateUserTicket call will fail because it can not authenticate the user.
Returns: dictionary
Contains the following keys:
Key | Type | Notes |
---|---|---|
handle | uint32_t | A handle to the auth ticket. |
buffer | PackedByteArray | The new auth ticket if the call was successful. |
size | uint32_t | Returns the length of the actual ticket. |
When you're done interacting with the entity you must call cancelAuthTicket on the handle.
Triggers
get_auth_session_ticket_response callback
getNextOutgoingPacket
getNextOutgoingPacket( )
Gets a packet that the master server updater needs to send out on UDP when in GameSocketShare mode. GameSocketShare mode can be enabled when calling serverInit.
This must be called repeatedly each frame until it returns 0 when in GameSocketShare mode.
Returns: dictionary
Contains the following keys:
Key | Type | Notes |
---|---|---|
length | int | The length of the packet that needs to be to sent or 0 if there are no more packets to send this frame. |
out | PackedByteArray | The packet that needs to be sent. |
address | uint32_t | Returns the The IP address that this packet needs to be sent to, in host order. |
port | uint16 | Returns the port that this packet needs to be sent through, in host order. |
Notes
This should only ever be called after calling handleIncomingPacket for any packets that came in that frame.
getPublicIP
getPublicIP( )
Gets the public IP of the server according to Steam. This is useful when the server is behind NAT and you want to advertise its IP in a lobby for other clients to directly connect to.
Returns: dictionary
Contains the following keys:
Key | Type | Notes |
---|---|---|
ipv4 | int | The public IPv4 address, if available. |
ipv6 | int | The public IPv6 address, if available. |
type | IPType enum | The type of IP address returned. |
getSteamID
getSteamID( )
Gets the Steam ID of the game server.
Returns: uint64_t
handleIncomingPacket
handleIncomingPacket( int
packet, string
ip, uint16
port )
Parameter | Type | Notes |
---|---|---|
packet | int | The packet handle. |
ip | string | The IP address that this packet was sent to in host order, i.e 127.0.0.1. |
port | uint16 | The port that this packet was sent through, in host order. |
Handles a Steam master server packet when in GameSocketShare mode. When in GameSocketShare mode, instead of ISteamGameServer creating its own socket to talk to the master server on, it lets the game use its socket to forward messages back and forth. This prevents us from requiring server ops to open up yet another port in their firewalls.
This should be called whenever a packet that starts with 0xFFFFFFFF comes in. That means it's for us. The IP and port parameters are used when you've elected to multiplex the game server's UDP socket rather than having the master server updater use its own sockets.
Source engine games use this to simplify the job of the server admins, so they don't have to open up more ports on their firewalls. Only after calling this, you should call getNextOutgoingPacket. GameSocketShare mode can be enabled when calling serverInit or serverInitEx.
Returns: dictionary
Contains the following key:
Key | Type | Notes |
---|---|---|
incoming | bool | Is there an incoming packet for us? |
data | PackedByteArray | The data from the incoming packet. |
loggedOn
loggedOn( )
Checks if the game server is logged on.
Returns: bool
Returns true if the game server is logged on; otherwise, false.
logOff
logOff( )
Begin process of logging game server out of Steam.
Returns: void
Triggers
- server_connect_failure callback
- server_connected callback
- server_disconnected callback
logOn
logOn( string
token )
Parameter | Type | Notes |
---|---|---|
token | string | - |
Begin process to login to a persistent game server account.
Returns: void
Triggers
- server_connect_failure callback
- server_connected callback
- server_disconnected callback
logOnAnonymous
logOnAnonymous( )
Login to a generic, anonymous account.
Returns: void
Triggers
- server_connect_failure callback
- server_connected callback
- server_disconnected callback
Notes
In previous versions of the SDK, this was automatically called within serverInit, but this is no longer the case.
requestUserGroupStatus
requestUserGroupStatus( uint64_t
steam_id, uint64_t
group_id )
Parameter | Type | Notes |
---|---|---|
steam_id | uint64_t | The user to check the group status of. |
group_id | uint64_t | The group to check. |
Ask if user is in the specified group; results returned by client_group_status.
Returns: bool
Returns false if we're not connected to the steam servers and thus cannot ask.
Triggers
client_group_status callback
secure
secure( )
Checks whether the game server is in "Secure" mode.
Returns: bool
Returns true if the game server secure; otherwise, false.
setAdvertiseServerActive
setAdvertiseServerActive( bool
active )
Parameter | Type | Notes |
---|---|---|
active | bool | Whether to set as active or not. |
Indicate whether you wish to be listed on the master server list and / or respond to server browser / LAN discovery packets.
The server starts with this value set to false. You should set all relevant server parameters before enabling advertisement on the server.
Returns: void
Notes
This function used to be named EnableHeartbeats, so if you are wondering where that function went, it's right here. It does the same thing as before, the old name was just confusing.
setBotPlayerCount
setBotPlayerCount( int
bots )
Parameter | Type | Notes |
---|---|---|
bots | int | The number of bot / AI players currently playing on the server. |
Sets the number of bot / AI players on the game server. The default value is 0.
Returns: void
setDedicatedServer
setDedicatedServer( bool
dedicated )
Parameter | Type | Notes |
---|---|---|
dedicated | bool | Is this a dedicated server (true) or a listen server (false)? |
Sets the whether this is a dedicated server or a listen server. The default is listen server.
Returns: void
Notes
This only be set before calling logOn or logOnAnonymous.
setGameData
setGameData( string
data )
Parameter | Type | Notes |
---|---|---|
data | string | The new "gamedata" value to set. Must not be an empty string. This can not be longer than MAX_GAME_SERVER_GAME_DATA (2048). |
Sets a string defining the "gamedata" for this server, this is optional, but if set it allows users to filter in the matchmaking/server-browser interfaces based on the value. Maximum of MAX_GAME_SERVER_GAME_DATA (2048)
This is usually formatted as a comma or semicolon separated list. Don't set this unless it actually changes, its only uploaded to the master once; when acknowledged.
Returns: void
setGameDescription
setGameDescription( string
description )
Parameter | Type | Notes |
---|---|---|
description | string | The description of your game. Must not be an empty string. This can not be longer than MAX_GAME_SERVER_GAME_DESCRIPTION (64). |
Description of the game. This is a required field, but it will go away eventually, as the data should be determined from the AppID.
Setting this to the full name of your game is recommended.
Returns: void
Notes
This is required for all game servers and can only be set before calling logOn or logOnAnonymous.
setGameTags
setGameTags( string
tags )
Parameter | Type | Notes |
---|---|---|
tags | string | The new "gametags" value to set. Must not be NULL or an empty string (""). This can not be longer than MAX_GAME_SERVER_TAGS (128). |
Sets a string defining the "gametags" for this server, this is optional, but if set it allows users to filter in the matchmaking/server-browser interfaces based on the value. Maximum of MAX_GAME_SERVER_TAGS (128)
This is usually formatted as a comma or semicolon separated list. Don't set this unless it actually changes, its only uploaded to the master once; when acknowledged.
Returns: void
setKeyValue
setKeyValue( string
key, string
value )
Parameter | Type | Notes |
---|---|---|
key | string | The key being set. |
value | string | The value set for this key. |
Add / update a rules key / value pair.
Returns: void
setMapName
setMapName( string
map )
Parameter | Type | Notes |
---|---|---|
map | string | The new map name to set. Must not be an empty string. This can not be longer than MAX_GAME_SERVER_MAP_NAME (32). |
Sets the name of map to report in the server browser.
Returns: void
setMaxPlayerCount
setMaxPlayerCount( int
players_max )
Parameter | Type | Notes |
---|---|---|
players_max | int | The new maximum number of players allowed on this server. |
Max player count that will be reported to server browser and client queries. This value may be changed at any time.
Returns: void
setModDir
setModDir( string
mod_directory )
Parameter | Type | Notes |
---|---|---|
mod_directory | string | The game directory to set. Must not be an empty string. This can not be longer than MAX_GAME_SERVER_GAME_DIR (32). |
Sets the game directory. This should be the same directory game where gets installed into. Just the folder name, not the whole path. e.g. "Spacewar".
Returns: void
Notes
This is required for all game servers and can only be set before calling logOn or logOnAnonymous.
setPasswordProtected
setPasswordProtected( bool
password_protected )
Parameter | Type | Notes |
---|---|---|
password_protected | bool | Enable (true) or disable (false) password protection. |
Set whether the game server will require a password once when the user tries to join.
Returns: void
setProduct
setProduct( string
product )
Parameter | Type | Notes |
---|---|---|
product | string | The unique identifier for your game. Must not be an empty string. |
Sets the game product identifier. This is currently used by the master server for version checking purposes.
It's a required field, but will eventually will go away, and the app ID will be used for this purpose. For now, converting the game's app ID to a string for this is recommended.
Returns: void
Notes
This is required for all game servers and can only be set before calling logOn or logOnAnonymous.
setRegion
setRegion( string
region )
Parameter | Type | Notes |
---|---|---|
region | string | - |
Region identifier. This is an optional field, the default value is an empty string, meaning the "world" region.
Returns: void
setServerName
setServerName( string
name )
Parameter | Type | Notes |
---|---|---|
name | string | The new server name to set. Must not be an empty string. This can not be longer than MAX_GAME_SERVER_NAME (64). |
Sets the name of server as it will appear in the server browser.
Returns: void
setSpectatorPort
setSpectatorPort( int
port )
Parameter | Type | Notes |
---|---|---|
port | int | The port for spectators to join. |
Spectator server port to advertise. The default value is zero, meaning the service is not used. If your server receives any info requests on the LAN, this is the value that will be placed into the reply for such local queries.
This is also the value that will be advertised by the master server. The only exception is if your server is using a fakeIP. Then the second fake port number (index 1) assigned to your server will be listed on the master server as the spectator port, if you set this value to any non-zero value.
This function merely controls the values that are advertised, it's up to you to configure the server to actually listen on this port and handle any spectator traffic.
Returns: void
setSpectatorServerName
setSpectatorServerName( string
name )
Parameter | Type | Notes |
---|---|---|
name | string | The spectator server name to set. Must not be an empty string. This can not be longer than MAX_GAME_SERVER_MAP_NAME. |
Sets the name of the spectator server. This is only used if spectator port is non-zero.
Returns: void
updateUserData
updateUserData( uint64_t
steam_id, string
player_name, uint32_t
score )
Parameter | Type | Notes |
---|---|---|
steam_id | uint64_t | The Steam ID of the user. |
player_name | string | The name of the user. |
score | uint32_t | The current score of the user. |
Update the data to be displayed in the server browser and matchmaking interfaces for a user currently connected to the server.
Returns: bool
Returns true if successful; otherwise, false if failure; ie, steam_id wasn't for an active player.
userHasLicenseForApp
userHasLicenseForApp( uint64_t
steam_id, uint32_t
app_id )
Parameter | Type | Notes |
---|---|---|
steam_id | uint64_t | The Steam ID of the user that sent the auth ticket. |
app_id | uint32_t | The DLC app ID to check if the user owns it. |
Checks if the user owns a specific piece of Downloadable Content (DLC). This can only be called after sending the users auth ticket to beginAuthSession.
Returns: UserHasLicenseForAppResult enum
wasRestartRequested
wasRestartRequested( )
Checks if the master server has alerted us that we are out of date and has requested a restart. This reverts back to false after calling this function. Only returns true once per request.
Returns: bool
Signals
These callbacks require you to setup one of the three callback methods to receive them.
associate_clan
associate_clan
Sent as a reply to associateWithClan.
Returns
Key | Type | Notes |
---|---|---|
result | Result enum | Result of the call. |
client_approved
client_approved
Client has been approved to connect to this game server.
Returns
Key | Type | Notes |
---|---|---|
steam_id | uint64_t | Steam ID of approved player. |
owner_id | uint64_t | Steam ID of original owner for game license. |
client_denied
client_denied
Client has been denied to connection to this game server.
Emits signal in response to function sendUserConnectAndAuthenticate (currently missing from Server).
Returns
Key | Type | Notes |
---|---|---|
steam_id | uint64_t | The Steam ID of the user that attempted to connect. |
reason | DenyReason enum | The reason the player was denied. |
optional_message | string | An optional text message explaining the deny reason. Typically unused except for logging. |
client_group_status
client_group_status
Sent as a reply to requestUserGroupStatus.
Returns
Key | Type | Notes |
---|---|---|
steam_id | uint64_t | The user whose group status we queried. |
group_id | uint64_t | The group that we queried. |
member | bool | Is the user a member of the group (true) or not (false)? |
officer | bool | Is the user an officer in the group (true) or not (false)? This will never be true if member is false. |
client_kick
client_kick
Request the game server should kick the user.
Returns
Key | Type | Notes |
---|---|---|
steam_id | uint64_t | The Steam ID of the player that should be kicked. |
reason | DenyReason enum | The reason the player is being kicked. |
gamplay_stats
gameplay_stats
GameServer gameplay stats info.
Returns
Key | Type | Notes |
---|---|---|
result | Result enum | The result of the operation. |
rank | int32_t | The overall rank of the server (0-based). |
total_connects | uint32_t | Total number of clients who have ever connected to the server. |
total_minutes_played | uint32_t | Total number of minutes ever played on the server. |
player_compat
player_compat
Sent as a reply to computeNewPlayerCompatibility.
Returns
Key | Type | Notes |
---|---|---|
result | Result enum | The result of the operation. Possible values: RESULT_OK on success, RESULT_FAIL for generic failures, RESULT_TIMEOUT if the message was sent to the Steam servers but it didn't respond, RESULT_NO_CONNECTION if your Steam client doesn't have a connection to the back-end. |
players_dont_like_candidate | int | The number of current players that don't like playing with the specified player. |
players_candidate_doesnt_like | int | The number of players on the server that the specified player doesn't like playing with. |
clan_players_dont_like_candidate | int | The number of players in the associated Steam group that don't like playing with the player. |
steam_id | uint64_t | The Steam ID of the specified player. |
policy_response
policy_response
Received when the game server requests to be displayed as secure (VAC protected).
Returns
Key | Type | Notes |
---|---|---|
secure | uint8 | Secure is true if the game server should display itself as secure to users; otherwise, false. |
server_connect_failure
server_connect_failure
Logging the game server onto Steam.
Emits signal in response to functions logOff, logOn, or logOnAnonymous.
Returns
Key | Type | Notes |
---|---|---|
result | Result enum | The reason why the connection failed. |
retrying | bool | Is the Steam client still trying to connect to the server? |
server_connected
server_connected
Server has connected to the Steam back-end.
Emits signal in response to functions logOff, logOn, or logOnAnonymous.
Returns
Nothing.
server_disconnected
server_disconnected
Called if the client has lost connection to the Steam servers. Real-time services will be disabled until a matching server_connected has been posted.
Emits signal in response to functions logOff, logOn, or logOnAnonymous.
Returns
Key | Type | Notes |
---|---|---|
result | Result enum | The reason we were disconnected from Steam. |