Struct steamworks::Matchmaking

source ·
pub struct Matchmaking<Manager> { /* private fields */ }
Expand description

Access to the steam matchmaking interface

Implementations§

source§

impl<Manager> Matchmaking<Manager>

source

pub fn request_lobby_list<F>(&self, cb: F)
where F: FnOnce(SResult<Vec<LobbyId>>) + 'static + Send,

source

pub fn create_lobby<F>(&self, ty: LobbyType, max_members: u32, cb: F)
where F: FnOnce(SResult<LobbyId>) + 'static + Send,

Attempts to create a new matchmaking lobby

The lobby with have the visibility of the of the passed LobbyType and a limit of max_members inside it. The max_members may not be higher than 250.

§Triggers
  • LobbyEnter
  • LobbyCreated
source

pub fn join_lobby<F>(&self, lobby: LobbyId, cb: F)
where F: FnOnce(Result<LobbyId, ()>) + 'static + Send,

Tries to join the lobby with the given ID

source

pub fn lobby_data_count(&self, lobby: LobbyId) -> u32

Returns the number of data keys in the lobby

source

pub fn lobby_data(&self, lobby: LobbyId, key: &str) -> Option<&str>

Returns the lobby metadata associated with the specified key from the specified lobby.

source

pub fn lobby_data_by_index( &self, lobby: LobbyId, idx: u32 ) -> Option<(String, String)>

Returns the lobby metadata associated with the specified index

source

pub fn set_lobby_data(&self, lobby: LobbyId, key: &str, value: &str) -> bool

Sets the lobby metadata associated with the specified key in the specified lobby.

source

pub fn delete_lobby_data(&self, lobby: LobbyId, key: &str) -> bool

Deletes the lobby metadata associated with the specified key in the specified lobby.

source

pub fn leave_lobby(&self, lobby: LobbyId)

Exits the passed lobby

source

pub fn lobby_member_limit(&self, lobby: LobbyId) -> Option<usize>

Returns the current limit on the number of players in a lobby.

Returns [None] if no metadata is available for the specified lobby.

source

pub fn lobby_owner(&self, lobby: LobbyId) -> SteamId

Returns the steam id of the current owner of the passed lobby

source

pub fn lobby_member_count(&self, lobby: LobbyId) -> usize

Returns the number of players in a lobby.

Useful if you are not currently in the lobby

source

pub fn lobby_members(&self, lobby: LobbyId) -> Vec<SteamId>

Returns a list of members currently in the lobby

source

pub fn set_lobby_joinable(&self, lobby: LobbyId, joinable: bool) -> bool

Sets whether or not a lobby is joinable by other players. This always defaults to enabled for a new lobby.

If joining is disabled, then no players can join, even if they are a friend or have been invited.

Lobbies with joining disabled will not be returned from a lobby search.

Returns true on success, false if the current user doesn’t own the lobby.

source

pub fn send_lobby_chat_message( &self, lobby: LobbyId, msg: &[u8] ) -> Result<(), SteamError>

Broadcasts a chat message (text or binary data) to all users in the lobby.

§Parameters
  • lobby: The Steam ID of the lobby to send the chat message to.
  • msg: This can be text or binary data, up to 4 Kilobytes in size.
§Description

All users in the lobby (including the local user) will receive a LobbyChatMsg_t callback with the message.

If you’re sending binary data, you should prefix a header to the message so that you know to treat it as your custom data rather than a plain old text message.

For communication that needs to be arbitrated (e.g., having a user pick from a set of characters), you can use the lobby owner as the decision maker. GetLobbyOwner returns the current lobby owner. There is guaranteed to always be one and only one lobby member who is the owner. So for the choose-a-character scenario, the user who is picking a character would send the binary message ‘I want to be Zoe’, the lobby owner would see that message, see if it was OK, and broadcast the appropriate result (user X is Zoe).

These messages are sent via the Steam back-end, and so the bandwidth available is limited. For higher-volume traffic like voice or game data, you’ll want to use the Steam Networking API.

§Returns

Returns Ok(()) if the message was successfully sent. Returns an error of type SteamError if the message is too small or too large, or if no connection to Steam could be made.

source

pub fn add_request_lobby_list_string_filter( &self, StringFilter: StringFilter<'_> ) -> &Self

Adds a string comparison filter to the lobby list request.

This method adds a filter that compares a specific string attribute in lobbies with the provided value. Lobbies matching this criterion will be included in the result.

§Arguments
  • key: The attribute key to compare.
  • value: The value to compare against.
source

pub fn add_request_lobby_list_numerical_filter( &self, NumberFilter: NumberFilter<'_> ) -> &Self

Adds a numerical comparison filter to the lobby list request.

This method adds a filter that compares a specific numerical attribute in lobbies with the provided value. Lobbies matching this criterion will be included in the result.

§Arguments
  • key: The attribute key to compare.
  • value: The value to compare against.
source

pub fn add_request_lobby_list_near_value_filter( &self, NearFilter: NearFilter<'_> ) -> &Self

Adds a near value filter to the lobby list request.

This method adds a filter that sorts the lobby results based on their closeness to a specific value. No actual filtering is performed; lobbies are sorted based on proximity.

§Arguments
  • key: The attribute key to use for sorting.
  • value: The reference value for sorting.
source

pub fn set_request_lobby_list_slots_available_filter( &self, open_slots: u8 ) -> &Self

Adds a filter for available open slots to the lobby list request.

This method adds a filter that includes lobbies having a specific number of open slots.

§Arguments
  • open_slots: The number of open slots in a lobby to filter by.
source

pub fn set_request_lobby_list_distance_filter( &self, distance: DistanceFilter ) -> &Self

Adds a distance filter to the lobby list request.

This method adds a filter that includes lobbies within a certain distance criterion.

§Arguments
  • distance: The DistanceFilter indicating the distance criterion for the filter.
source

pub fn set_request_lobby_list_result_count_filter(&self, count: u64) -> &Self

Adds a result count filter to the lobby list request.

This method adds a filter to limit the number of lobby results returned by the request.

§Arguments
  • count: The maximum number of lobby results to include in the response.
source

pub fn set_lobby_list_filter(&self, filter: LobbyListFilter<'_>) -> &Self

Sets filters for the lobbies to be returned from request_lobby_list.

This method is used to apply various filters to the lobby list retrieval process. Call this method before calling request_lobby_list to ensure that the specified filters are taken into account when fetching the list of available lobbies.

§Arguments
  • filter: A LobbyListFilter struct containing the filter criteria to be applied.
§Example
fn main() {
    let (client, single) = Client::init().unwrap();
    client.matchmaking().set_lobby_list_filter(
        LobbyListFilter {
            string: Some(vec![
                StringFilter(
                    LobbyKey::new("name"), "My Lobby", StringFilterKind::Include
                ),
                StringFilter(
                    LobbyKey::new("gamemode"), "ffa", StringFilterKind::Include
                ),
            ]),
            number: Some(vec![
                NumberFilter("elo", 1500, ComparisonFilter::GreaterThan),
                NumberFilter("elo", 2000, ComparisonFilter::LessThan)
            ]),
            ..Default::default()
        }
    ).request_lobby_list(|lobbies| {
        println!("Lobbies: {:?}", lobbies);
    });
}

Auto Trait Implementations§

§

impl<Manager> RefUnwindSafe for Matchmaking<Manager>
where Manager: RefUnwindSafe,

§

impl<Manager> !Send for Matchmaking<Manager>

§

impl<Manager> !Sync for Matchmaking<Manager>

§

impl<Manager> Unpin for Matchmaking<Manager>

§

impl<Manager> UnwindSafe for Matchmaking<Manager>
where Manager: RefUnwindSafe,

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, 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.