Struct steamworks::Server

source ·
pub struct Server { /* private fields */ }
Expand description

The main entry point into the steam client for servers.

This provides access to all of the steamworks api that servers can use.

Implementations§

source§

impl Server

source

pub fn init( ip: Ipv4Addr, game_port: u16, query_port: u16, server_mode: ServerMode, version: &str ) -> SIResult<(Server, SingleClient<ServerManager>)>

Attempts to initialize the steamworks api and returns a server to access the rest of the api.

This should only ever have one instance per a program.

Currently the steamworks api doesn’t support IPv6.

§Errors

This can fail if:

  • The steam client isn’t running

  • The app ID of the game couldn’t be determined.

    If the game isn’t being run through steam this can be provided by placing a steam_appid.txt with the ID inside in the current working directory

  • The game isn’t running on the same user/level as the steam client

  • The user doesn’t own a license for the game.

  • The app ID isn’t completely set up.

source

pub fn register_callback<C, F>(&self, f: F) -> CallbackHandle<ServerManager>
where C: Callback, F: FnMut(C) + 'static + Send,

Registers the passed function as a callback for the given type.

The callback will be run on the thread that run_callbacks is called when the event arrives.

source

pub fn steam_id(&self) -> SteamId

Returns the steam id of the current server

source

pub fn authentication_session_ticket_with_steam_id( &self, steam_id: SteamId ) -> (AuthTicket, Vec<u8>)

Retrieve an authentication session ticket that can be sent to an entity that wishes to verify you.

This ticket should not be reused.

When creating ticket for use by the web API you should wait for the AuthSessionTicketResponse event before trying to use the ticket.

When the multiplayer session terminates you must call cancel_authentication_ticket

source

pub fn authentication_session_ticket( &self, network_identity: NetworkingIdentity ) -> (AuthTicket, Vec<u8>)

source

pub fn cancel_authentication_ticket(&self, ticket: AuthTicket)

Cancels an authentication session ticket received from authentication_session_ticket.

This should be called when you are no longer playing with the specified entity.

source

pub fn begin_authentication_session( &self, user: SteamId, ticket: &[u8] ) -> Result<(), AuthSessionError>

Authenticate the ticket from the steam ID to make sure it is valid and not reused.

A ValidateAuthTicketResponse callback will be fired if the entity goes offline or cancels the ticket.

When the multiplayer session terminates you must call end_authentication_session

source

pub fn end_authentication_session(&self, user: SteamId)

Ends an authentication session that was started with begin_authentication_session.

This should be called when you are no longer playing with the specified entity.

source

pub fn set_product(&self, product: &str)

Sets the game product identifier. This is currently used by the master server for version checking purposes. Converting the games app ID to a string for this is recommended.

This is required for all game servers and can only be set before calling log_on() or log_on_anonymous().

source

pub fn set_game_description(&self, desc: &str)

Sets the game description. Setting this to the full name of your game is recommended.

This is required for all game servers and can only be set before calling log_on() or log_on_anonymous().

source

pub fn set_dedicated_server(&self, dedicated: bool)

Sets whether this server is dedicated or a listen server.

source

pub fn log_on_anonymous(&self)

Login to a generic anonymous account

source

pub fn enable_heartbeats(&self, active: bool)

If active, updates the master server with this server’s presence so players can find it via the steam matchmaking/server browser interfaces.

source

pub fn set_mod_dir(&self, mod_dir: &str)

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.

source

pub fn set_map_name(&self, map_name: &str)

Set name of map to report in the server browser

source

pub fn set_server_name(&self, server_name: &str)

Set the name of server as it will appear in the server browser

source

pub fn set_max_players(&self, count: i32)

Sets the maximum number of players allowed on the server at once.

This value may be changed at any time.

source

pub fn ugc(&self) -> UGC<ServerManager>

Returns an accessor to the steam UGC interface (steam workshop)

For this to work properly, you need to call UGC::init_for_game_server()!

Trait Implementations§

source§

impl Clone for Server

source§

fn clone(&self) -> Server

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Send for Server

source§

impl Sync for Server

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.