docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class SteamGameServer

    Purpose: Functions for authenticating users via Steam to play on a game server

    Inheritance
    object
    SteamGameServer
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.Steamworks.Interop
    Assembly: Unity.Steamworks.Interop.dll
    Syntax
    public static class SteamGameServer

    Methods

    AssociateWithClan(CSteamID)

    Server clan association associate this game server with this clan for the purposes of computing player compat

    Declaration
    public static SteamAPICall_t AssociateWithClan(CSteamID steamIDClan)
    Parameters
    Type Name Description
    CSteamID steamIDClan

    Passed through to ISteamGameServer::AssociateWithClan.

    Returns
    Type Description
    SteamAPICall_t

    The value ISteamGameServer::AssociateWithClan returns.

    AssociateWithClanAsync(CSteamID)

    Async version of AssociateWithClan(CSteamID).

    Declaration
    public static Task<AssociateWithClanResult_t> AssociateWithClanAsync(CSteamID steamIDClan)
    Parameters
    Type Name Description
    CSteamID steamIDClan

    Passed through to ISteamGameServer::AssociateWithClan.

    Returns
    Type Description
    Task<AssociateWithClanResult_t>

    The AssociateWithClanResult_t Steam reports once the call completes.

    BLoggedOn()

    status functions

    Declaration
    public static bool BLoggedOn()
    Returns
    Type Description
    bool

    The value ISteamGameServer::BLoggedOn returns.

    BSecure()

    Calls the Steamworks ISteamGameServer::BSecure method.

    Declaration
    public static bool BSecure()
    Returns
    Type Description
    bool

    The value ISteamGameServer::BSecure returns.

    BUpdateUserData(CSteamID, string, uint)

    Update the data to be displayed in the server browser and matchmaking interfaces for a user currently connected to the server. For regular users you must call this after you receive a GSUserValidationSuccess callback. Return Value: true if successful, false if failure (ie, steamIDUser wasn't for an active player)

    Declaration
    public static bool BUpdateUserData(CSteamID steamIDUser, string pchPlayerName, uint uScore)
    Parameters
    Type Name Description
    CSteamID steamIDUser

    Passed through to ISteamGameServer::BUpdateUserData.

    string pchPlayerName

    Passed through to ISteamGameServer::BUpdateUserData.

    uint uScore

    Passed through to ISteamGameServer::BUpdateUserData.

    Returns
    Type Description
    bool

    The value ISteamGameServer::BUpdateUserData returns.

    BeginAuthSession(byte[], int, CSteamID)

    Authenticate ticket ( from GetAuthSessionTicket ) from entity steamID to be sure it is valid and isnt reused Registers for callbacks if the entity goes offline or cancels the ticket ( see ValidateAuthTicketResponse_t callback and EAuthSessionResponse )

    Declaration
    public static EBeginAuthSessionResult BeginAuthSession(byte[] pAuthTicket, int cbAuthTicket, CSteamID steamID)
    Parameters
    Type Name Description
    byte[] pAuthTicket

    Passed through to ISteamGameServer::BeginAuthSession.

    int cbAuthTicket

    Passed through to ISteamGameServer::BeginAuthSession.

    CSteamID steamID

    Passed through to ISteamGameServer::BeginAuthSession.

    Returns
    Type Description
    EBeginAuthSessionResult

    The value ISteamGameServer::BeginAuthSession returns.

    CancelAuthTicket(HAuthTicket)

    Cancel auth ticket from GetAuthSessionTicket, called when no longer playing game with the entity you gave the ticket to

    Declaration
    public static void CancelAuthTicket(HAuthTicket hAuthTicket)
    Parameters
    Type Name Description
    HAuthTicket hAuthTicket

    Passed through to ISteamGameServer::CancelAuthTicket.

    ClearAllKeyValues()

    Call this to clear the whole list of key/values that are sent in rules queries.

    Declaration
    public static void ClearAllKeyValues()

    ComputeNewPlayerCompatibility(CSteamID)

    ask if any of the current players dont want to play with this new player - or vice versa

    Declaration
    public static SteamAPICall_t ComputeNewPlayerCompatibility(CSteamID steamIDNewPlayer)
    Parameters
    Type Name Description
    CSteamID steamIDNewPlayer

    Passed through to ISteamGameServer::ComputeNewPlayerCompatibility.

    Returns
    Type Description
    SteamAPICall_t

    The value ISteamGameServer::ComputeNewPlayerCompatibility returns.

    ComputeNewPlayerCompatibilityAsync(CSteamID)

    Async version of ComputeNewPlayerCompatibility(CSteamID).

    Declaration
    public static Task<ComputeNewPlayerCompatibilityResult_t> ComputeNewPlayerCompatibilityAsync(CSteamID steamIDNewPlayer)
    Parameters
    Type Name Description
    CSteamID steamIDNewPlayer

    Passed through to ISteamGameServer::ComputeNewPlayerCompatibility.

    Returns
    Type Description
    Task<ComputeNewPlayerCompatibilityResult_t>

    The ComputeNewPlayerCompatibilityResult_t Steam reports once the call completes.

    CreateUnauthenticatedUserConnection()

    Creates a fake user (ie, a bot) which will be listed as playing on the server, but skips validation. Return Value: 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.

    Declaration
    public static CSteamID CreateUnauthenticatedUserConnection()
    Returns
    Type Description
    CSteamID

    The value ISteamGameServer::CreateUnauthenticatedUserConnection returns.

    EndAuthSession(CSteamID)

    Stop tracking started by BeginAuthSession - called when no longer playing game with this entity

    Declaration
    public static void EndAuthSession(CSteamID steamID)
    Parameters
    Type Name Description
    CSteamID steamID

    Passed through to ISteamGameServer::EndAuthSession.

    GetAuthSessionTicket(byte[], int, out uint, ref SteamNetworkingIdentity)

    Player list management / authentication. Retrieve ticket to be sent to the entity who wishes to authenticate you ( using BeginAuthSession API ). pcbTicket retrieves the length of the actual ticket. SteamNetworkingIdentity is an optional parameter to hold the public IP address of the entity you are connecting to if an IP address is passed Steam will only allow the ticket to be used by an entity with that IP address

    Declaration
    public static HAuthTicket GetAuthSessionTicket(byte[] pTicket, int cbMaxTicket, out uint pcbTicket, ref SteamNetworkingIdentity pSnid)
    Parameters
    Type Name Description
    byte[] pTicket

    Passed through to ISteamGameServer::GetAuthSessionTicket.

    int cbMaxTicket

    Passed through to ISteamGameServer::GetAuthSessionTicket.

    uint pcbTicket

    Passed through to ISteamGameServer::GetAuthSessionTicket.

    SteamNetworkingIdentity pSnid

    Passed through to ISteamGameServer::GetAuthSessionTicket.

    Returns
    Type Description
    HAuthTicket

    The value ISteamGameServer::GetAuthSessionTicket returns.

    GetGameplayStats()

    these two functions s are deprecated, and will not return results they will be removed in a future version of the SDK

    Declaration
    public static void GetGameplayStats()

    GetNextOutgoingPacket(byte[], int, out uint, out ushort)

    AFTER calling HandleIncomingPacket for any packets that came in that frame, call this. This gets a packet that the master server updater needs to send out on UDP. It returns the length of the packet it wants to send, or 0 if there are no more packets to send. Call this each frame until it returns 0.

    Declaration
    public static int GetNextOutgoingPacket(byte[] pOut, int cbMaxOut, out uint pNetAdr, out ushort pPort)
    Parameters
    Type Name Description
    byte[] pOut

    Passed through to ISteamGameServer::GetNextOutgoingPacket.

    int cbMaxOut

    Passed through to ISteamGameServer::GetNextOutgoingPacket.

    uint pNetAdr

    Passed through to ISteamGameServer::GetNextOutgoingPacket.

    ushort pPort

    Passed through to ISteamGameServer::GetNextOutgoingPacket.

    Returns
    Type Description
    int

    The value ISteamGameServer::GetNextOutgoingPacket returns.

    GetPublicIP()

    Returns the public IP of the server according to Steam, useful when the server is behind NAT and you want to advertise its IP in a lobby for other clients to directly connect to

    Declaration
    public static SteamIPAddress_t GetPublicIP()
    Returns
    Type Description
    SteamIPAddress_t

    The value ISteamGameServer::GetPublicIP returns.

    GetServerReputation()

    Calls the Steamworks ISteamGameServer::GetServerReputation method.

    Declaration
    public static SteamAPICall_t GetServerReputation()
    Returns
    Type Description
    SteamAPICall_t

    The value ISteamGameServer::GetServerReputation returns.

    GetServerReputationAsync()

    Async version of GetServerReputation().

    Declaration
    public static Task<GSReputation_t> GetServerReputationAsync()
    Returns
    Type Description
    Task<GSReputation_t>

    The GSReputation_t Steam reports once the call completes.

    GetSteamID()

    Calls the Steamworks ISteamGameServer::GetSteamID method.

    Declaration
    public static CSteamID GetSteamID()
    Returns
    Type Description
    CSteamID

    The value ISteamGameServer::GetSteamID returns.

    HandleIncomingPacket(byte[], int, uint, ushort)

    Server browser related query packet processing for shared socket mode. These are used when you pass STEAMGAMESERVER_QUERY_PORT_SHARED as the query port to SteamGameServer_Init. IP address and port are in host order, i.e 127.0.0.1 == 0x7f000001 These 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 games use this to simplify the job of the server admins, so they don't have to open up more ports on their firewalls. Call this when a packet that starts with 0xFFFFFFFF comes in. That means it's for us.

    Declaration
    public static bool HandleIncomingPacket(byte[] pData, int cbData, uint srcIP, ushort srcPort)
    Parameters
    Type Name Description
    byte[] pData

    Passed through to ISteamGameServer::HandleIncomingPacket.

    int cbData

    Passed through to ISteamGameServer::HandleIncomingPacket.

    uint srcIP

    Passed through to ISteamGameServer::HandleIncomingPacket.

    ushort srcPort

    Passed through to ISteamGameServer::HandleIncomingPacket.

    Returns
    Type Description
    bool

    The value ISteamGameServer::HandleIncomingPacket returns.

    LogOff()

    Begin process of logging game server out of steam

    Declaration
    public static void LogOff()

    LogOn(string)

    Login Begin process to login to a persistent game server account You need to register for callbacks to determine the result of this operation. @see SteamServersConnected_t @see SteamServerConnectFailure_t @see SteamServersDisconnected_t

    Declaration
    public static void LogOn(string pszToken)
    Parameters
    Type Name Description
    string pszToken

    Passed through to ISteamGameServer::LogOn.

    LogOnAnonymous()

    Login to a generic, anonymous account. Note: in previous versions of the SDK, this was automatically called within SteamGameServer_Init, but this is no longer the case.

    Declaration
    public static void LogOnAnonymous()

    RequestUserGroupStatus(CSteamID, CSteamID)

    Ask if a user in in the specified group, results returns async by GSUserGroupStatus_t returns false if we're not connected to the steam servers and thus cannot ask

    Declaration
    public static bool RequestUserGroupStatus(CSteamID steamIDUser, CSteamID steamIDGroup)
    Parameters
    Type Name Description
    CSteamID steamIDUser

    Passed through to ISteamGameServer::RequestUserGroupStatus.

    CSteamID steamIDGroup

    Passed through to ISteamGameServer::RequestUserGroupStatus.

    Returns
    Type Description
    bool

    The value ISteamGameServer::RequestUserGroupStatus returns.

    SendUserConnectAndAuthenticate_DEPRECATED(uint, byte[], uint, out CSteamID)

    Handles receiving a new connection from a Steam user. This call will ask the Steam servers to validate the users identity, app ownership, and VAC status. If the Steam servers are off-line, then it will validate the cached ticket itself which will validate app ownership and identity. The AuthBlob here should be acquired on the game client using SteamUser()->InitiateGameConnection() and must then be sent up to the game server for authentication. Return Value: returns true if the users ticket passes basic checks. pSteamIDUser will contain the Steam ID of this user. pSteamIDUser must NOT be NULL If the call succeeds then you should expect a GSClientApprove_t or GSClientDeny_t callback which will tell you whether authentication for the user has succeeded or failed (the steamid in the callback will match the one returned by this call) DEPRECATED! This function will be removed from the SDK in an upcoming version. Please migrate to BeginAuthSession and related functions.

    Declaration
    public static bool SendUserConnectAndAuthenticate_DEPRECATED(uint unIPClient, byte[] pvAuthBlob, uint cubAuthBlobSize, out CSteamID pSteamIDUser)
    Parameters
    Type Name Description
    uint unIPClient

    Passed through to ISteamGameServer::SendUserConnectAndAuthenticate_DEPRECATED.

    byte[] pvAuthBlob

    Passed through to ISteamGameServer::SendUserConnectAndAuthenticate_DEPRECATED.

    uint cubAuthBlobSize

    Passed through to ISteamGameServer::SendUserConnectAndAuthenticate_DEPRECATED.

    CSteamID pSteamIDUser

    Passed through to ISteamGameServer::SendUserConnectAndAuthenticate_DEPRECATED.

    Returns
    Type Description
    bool

    The value ISteamGameServer::SendUserConnectAndAuthenticate_DEPRECATED returns.

    SendUserDisconnect_DEPRECATED(CSteamID)

    Should be called whenever a user leaves our game server, this lets Steam internally track which users are currently on which servers for the purposes of preventing a single account being logged into multiple servers, showing who is currently on a server, etc. DEPRECATED! This function will be removed from the SDK in an upcoming version. Please migrate to BeginAuthSession and related functions.

    Declaration
    public static void SendUserDisconnect_DEPRECATED(CSteamID steamIDUser)
    Parameters
    Type Name Description
    CSteamID steamIDUser

    Passed through to ISteamGameServer::SendUserDisconnect_DEPRECATED.

    SetAdvertiseServerActive(bool)

    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. (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.)

    Declaration
    public static void SetAdvertiseServerActive(bool bActive)
    Parameters
    Type Name Description
    bool bActive

    Passed through to ISteamGameServer::SetAdvertiseServerActive.

    SetBotPlayerCount(int)

    Number of bots. Default value is zero

    Declaration
    public static void SetBotPlayerCount(int cBotplayers)
    Parameters
    Type Name Description
    int cBotplayers

    Passed through to ISteamGameServer::SetBotPlayerCount.

    SetDedicatedServer(bool)

    Is this is a dedicated server? The default value is false.

    Declaration
    public static void SetDedicatedServer(bool bDedicated)
    Parameters
    Type Name Description
    bool bDedicated

    Passed through to ISteamGameServer::SetDedicatedServer.

    SetGameData(string)

    Sets a string defining the "gamedata" for this server, this is optional, but if it is set it allows users to filter in the matchmaking/server-browser interfaces based on the value @see k_cbMaxGameServerGameData

    Declaration
    public static void SetGameData(string pchGameData)
    Parameters
    Type Name Description
    string pchGameData

    Passed through to ISteamGameServer::SetGameData.

    SetGameDescription(string)

    Description of the game. This is a required field and is displayed in the steam server browser....for now. This is a required field, but it will go away eventually, as the data should be determined from the AppID.

    Declaration
    public static void SetGameDescription(string pszGameDescription)
    Parameters
    Type Name Description
    string pszGameDescription

    Passed through to ISteamGameServer::SetGameDescription.

    SetGameTags(string)

    Sets a string defining the "gametags" for this server, this is optional, but if it is set it allows users to filter in the matchmaking/server-browser interfaces based on the value @see k_cbMaxGameServerTags

    Declaration
    public static void SetGameTags(string pchGameTags)
    Parameters
    Type Name Description
    string pchGameTags

    Passed through to ISteamGameServer::SetGameTags.

    SetKeyValue(string, string)

    Call this to add/update a key/value pair.

    Declaration
    public static void SetKeyValue(string pKey, string pValue)
    Parameters
    Type Name Description
    string pKey

    Passed through to ISteamGameServer::SetKeyValue.

    string pValue

    Passed through to ISteamGameServer::SetKeyValue.

    SetMapName(string)

    Set name of map to report in the server browser @see k_cbMaxGameServerMapName

    Declaration
    public static void SetMapName(string pszMapName)
    Parameters
    Type Name Description
    string pszMapName

    Passed through to ISteamGameServer::SetMapName.

    SetMaxPlayerCount(int)

    Server state. These properties may be changed at any time. Max player count that will be reported to server browser and client queries

    Declaration
    public static void SetMaxPlayerCount(int cPlayersMax)
    Parameters
    Type Name Description
    int cPlayersMax

    Passed through to ISteamGameServer::SetMaxPlayerCount.

    SetModDir(string)

    If your game is a "mod," pass the string that identifies it. The default is an empty string, meaning this application is the original game, not a mod. @see k_cbMaxGameServerGameDir

    Declaration
    public static void SetModDir(string pszModDir)
    Parameters
    Type Name Description
    string pszModDir

    Passed through to ISteamGameServer::SetModDir.

    SetPasswordProtected(bool)

    Let people know if your server will require a password

    Declaration
    public static void SetPasswordProtected(bool bPasswordProtected)
    Parameters
    Type Name Description
    bool bPasswordProtected

    Passed through to ISteamGameServer::SetPasswordProtected.

    SetProduct(string)

    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 AppID will be used for this purpose.

    Declaration
    public static void SetProduct(string pszProduct)
    Parameters
    Type Name Description
    string pszProduct

    Passed through to ISteamGameServer::SetProduct.

    SetRegion(string)

    Region identifier. This is an optional field, the default value is empty, meaning the "world" region

    Declaration
    public static void SetRegion(string pszRegion)
    Parameters
    Type Name Description
    string pszRegion

    Passed through to ISteamGameServer::SetRegion.

    SetServerName(string)

    Set the name of server as it will appear in the server browser @see k_cbMaxGameServerName

    Declaration
    public static void SetServerName(string pszServerName)
    Parameters
    Type Name Description
    string pszServerName

    Passed through to ISteamGameServer::SetServerName.

    SetSpectatorPort(ushort)

    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 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 nonzero 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

    Declaration
    public static void SetSpectatorPort(ushort unSpectatorPort)
    Parameters
    Type Name Description
    ushort unSpectatorPort

    Passed through to ISteamGameServer::SetSpectatorPort.

    SetSpectatorServerName(string)

    Name of the spectator server. (Only used if spectator port is nonzero.) @see k_cbMaxGameServerMapName

    Declaration
    public static void SetSpectatorServerName(string pszSpectatorServerName)
    Parameters
    Type Name Description
    string pszSpectatorServerName

    Passed through to ISteamGameServer::SetSpectatorServerName.

    UserHasLicenseForApp(CSteamID, AppId_t)

    After receiving a user's authentication data, and passing it to SendUserConnectAndAuthenticate, use this function to determine if the user owns downloadable content specified by the provided AppID.

    Declaration
    public static EUserHasLicenseForAppResult UserHasLicenseForApp(CSteamID steamID, AppId_t appID)
    Parameters
    Type Name Description
    CSteamID steamID

    Passed through to ISteamGameServer::UserHasLicenseForApp.

    AppId_t appID

    Passed through to ISteamGameServer::UserHasLicenseForApp.

    Returns
    Type Description
    EUserHasLicenseForAppResult

    The value ISteamGameServer::UserHasLicenseForApp returns.

    WasRestartRequested()

    Returns true if the master server has requested a restart. Only returns true once per request.

    Declaration
    public static bool WasRestartRequested()
    Returns
    Type Description
    bool

    The value ISteamGameServer::WasRestartRequested returns.

    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)