useMatchmakingStore is a Pinia store that manages matchmaking queues, lobbies, friends, region selection, and latency testing for the 5Stack platform.
Overview
This store handles:- Matchmaking queue state and confirmations
- Lobby creation and management
- Friends list and online status
- Region selection and latency testing
- Match invitations
- Regional queue statistics
Import
Usage
State
Queue Management
Current matchmaking queue state containing:
details: Queue information (total players, type, regions)confirmation: Match confirmation state (when match is found)
Statistics showing number of players in queue per region and match type.
Social Features
List of all friends with their status and current activities.
Full player data for currently online players.
Array of Steam IDs for players currently online.
Pending match invitations received by the user.
Lobbies
All lobbies the user is part of or invited to.
ID of the match currently being viewed.
Region & Latency
Latency test results for each region.
User’s manually selected preferred regions.
Maximum latency (in ms) the user is willing to accept. Default: 75ms
Indicates whether latency tests are currently running.
Methods
Lobby Management
createLobby()
Creates a new matchmaking lobby.string - The ID of the newly created lobby
Example:
inviteToLobby()
Invites a player to your lobby. Creates a new lobby if you’re not in one.Steam ID of the player to invite
Latency & Region Management
refreshLatencies()
Runs latency tests for all available regions.checkLatenies()
Checks if latencies have been tested, and runs tests if not.getRegionlatencyResult()
Gets the latency test result for a specific region.Region code to get latency for
isLan flag and latency string, or undefined if not tested
Example:
togglePreferredRegion()
Toggles a region in/out of the user’s preferred regions list.Region code to toggle
updateMaxAcceptableLatency()
Updates the maximum acceptable latency threshold.Maximum latency in milliseconds
Computed Properties
Friends who are currently online (excludes pending friend requests).
Friends who are currently offline (excludes pending friend requests).
Lobbies the user is invited to but not currently in.
The lobby the user is currently in.
Filtered and sorted list of regions based on user preferences and latency:
- Filters out regions exceeding max acceptable latency
- Prioritizes manually selected regions
- Sorts by LAN status and latency
Real-time Subscriptions
The store automatically subscribes to:- Friends list and their online status
- Match invitations
- Lobby memberships and updates
Example: Region Selection UI
Example: Queue Status Display
Local Storage Keys
The store persists data to localStorage:5stack_region_latency_{region}- Latency test results per region5stack_max_acceptable_latency- User’s max acceptable latency setting5stack_preferred_regions- User’s manually selected preferred regions