Struct steamworks::Matchmaking
source · pub struct Matchmaking<Manager> { /* private fields */ }
Expand description
Access to the steam matchmaking interface
Implementations§
source§impl<Manager> Matchmaking<Manager>
impl<Manager> Matchmaking<Manager>
pub fn request_lobby_list<F>(&self, cb: F)
sourcepub fn create_lobby<F>(&self, ty: LobbyType, max_members: u32, cb: F)
pub fn create_lobby<F>(&self, ty: LobbyType, max_members: u32, cb: F)
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
sourcepub fn join_lobby<F>(&self, lobby: LobbyId, cb: F)
pub fn join_lobby<F>(&self, lobby: LobbyId, cb: F)
Tries to join the lobby with the given ID
sourcepub fn lobby_data_count(&self, lobby: LobbyId) -> u32
pub fn lobby_data_count(&self, lobby: LobbyId) -> u32
Returns the number of data keys in the lobby
sourcepub fn lobby_data(&self, lobby: LobbyId, key: &str) -> Option<&str>
pub fn lobby_data(&self, lobby: LobbyId, key: &str) -> Option<&str>
Returns the lobby metadata associated with the specified key from the specified lobby.
sourcepub fn lobby_data_by_index(
&self,
lobby: LobbyId,
idx: u32
) -> Option<(String, String)>
pub fn lobby_data_by_index( &self, lobby: LobbyId, idx: u32 ) -> Option<(String, String)>
Returns the lobby metadata associated with the specified index
sourcepub fn set_lobby_data(&self, lobby: LobbyId, key: &str, value: &str) -> bool
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.
sourcepub fn delete_lobby_data(&self, lobby: LobbyId, key: &str) -> bool
pub fn delete_lobby_data(&self, lobby: LobbyId, key: &str) -> bool
Deletes the lobby metadata associated with the specified key in the specified lobby.
sourcepub fn leave_lobby(&self, lobby: LobbyId)
pub fn leave_lobby(&self, lobby: LobbyId)
Exits the passed lobby
sourcepub fn lobby_member_limit(&self, lobby: LobbyId) -> Option<usize>
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.
sourcepub fn lobby_owner(&self, lobby: LobbyId) -> SteamId
pub fn lobby_owner(&self, lobby: LobbyId) -> SteamId
Returns the steam id of the current owner of the passed lobby
sourcepub fn lobby_member_count(&self, lobby: LobbyId) -> usize
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
sourcepub fn lobby_members(&self, lobby: LobbyId) -> Vec<SteamId>
pub fn lobby_members(&self, lobby: LobbyId) -> Vec<SteamId>
Returns a list of members currently in the lobby
sourcepub fn set_lobby_joinable(&self, lobby: LobbyId, joinable: bool) -> bool
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.
sourcepub fn send_lobby_chat_message(
&self,
lobby: LobbyId,
msg: &[u8]
) -> Result<(), SteamError>
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.
sourcepub fn add_request_lobby_list_string_filter(
&self,
StringFilter: StringFilter<'_>
) -> &Self
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.
sourcepub fn add_request_lobby_list_numerical_filter(
&self,
NumberFilter: NumberFilter<'_>
) -> &Self
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.
sourcepub fn add_request_lobby_list_near_value_filter(
&self,
NearFilter: NearFilter<'_>
) -> &Self
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.
sourcepub fn set_request_lobby_list_slots_available_filter(
&self,
open_slots: u8
) -> &Self
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.
sourcepub fn set_request_lobby_list_distance_filter(
&self,
distance: DistanceFilter
) -> &Self
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
: TheDistanceFilter
indicating the distance criterion for the filter.
sourcepub fn set_request_lobby_list_result_count_filter(&self, count: u64) -> &Self
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.
sourcepub fn set_lobby_list_filter(&self, filter: LobbyListFilter<'_>) -> &Self
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
: ALobbyListFilter
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);
});
}