PICO Platform Unity SDK
MatchmakingService Class Reference

Static Public Member Functions

static Task ReportResultsInsecure (UInt64 roomId, Dictionary< string, int > data)
 Reports the result of a skill-rating match. More...
 
static Task< MatchmakingStatsGetStats (string pool, uint maxLevel, MatchmakingStatApproach approach=MatchmakingStatApproach.Trailing)
 Gets the matchmaking statistics for the current user. More...
 
static Task< MatchmakingBrowseResultBrowse2 (string pool, MatchmakingOptions matchmakingOptions=null)
 Gets rooms by matchmakinging pool name. The user can join the room with RoomService.Join2 toor cancel the retrieval with MatchmakingService.Cancel. More...
 
static Task< MatchmakingBrowseResultBrowse2ForCustomPage (string pool, MatchmakingOptions matchmakingOptions=null, int pageIndex=0, int pageSize=5)
 Gets rooms by matchmakinging pool name and specify the page number and the number of pages per page. More...
 
static Task Cancel ()
 Cancels a matchmaking request. Call this function to cancel an enqueue request before a match is made. This is typically triggered when a user gives up waiting. If you do not cancel the request but the user goes offline, the user/room will be timed out according to the setting of reserved period on the PICO Developer Platform. More...
 
static Task< MatchmakingEnqueueResultAndRoomCreateAndEnqueueRoom2 (string pool, MatchmakingOptions matchmakingOptions=null)
 Creates a matchmaking room, then enqueues and joins it. More...
 
static Task< MatchmakingEnqueueResultEnqueue2 (string pool, MatchmakingOptions matchmakingOptions=null)
 Enqueues for an available matchmaking room to join. When the server finds a match, it will return a message of type MessageType.Notification_Matchmaking_MatchFound. You can join found matching rooms by calling RoomService.Join2. If you want to cancel the match early, you can use MatchmakingService.Cancel. More...
 
static Task< MatchmakingAdminSnapshotGetAdminSnapshot ()
 Debugs the state of the current matchmaking pool queue. More...
 
static Task StartMatch (UInt64 roomId)
 Reports that a skill-rating match has started. You can use this method after joining the room. More...
 
static void SetMatchFoundNotificationCallback (Message< Room >.Handler handler)
 Sets the callback to get notified when a match has been found. For example, after calling MatchmakingService.Enqueue, when the match is successful, you will receive Notification_Matchmaking_MatchFound, and then execute the processing function set by this function. More...
 
static void SetCancel2NotificationCallback (Message.Handler handler)
 A notification will be sent to the player after they have been kicked out of the matchmaking pool. Listen to the event to receive a message. More...
 

Member Function Documentation

◆ ReportResultsInsecure()

static Task ReportResultsInsecure ( UInt64  roomId,
Dictionary< string, int >  data 
)
inlinestatic

Reports the result of a skill-rating match.

Note
Applicable to the following matchmaking modes: Quickmatch, Browse (+ Skill Pool)
Parameters
roomIdThe room ID.
dataThe key-value pairs.
Returns

Request information of type Task, including the request ID, and its response message does not contain data.

Error Code Error Message
3006209 match result report: not in match
3006210 match result report: error report data
3006211 match result report: duplicate report
3006212 match result report: conflict with other's report

Only for pools with skill-based matchmaking. Call this method after calling StartMatch() to begin a skill-rating match. After the match finishes, the server will record the result and update the skill levels of all players involved based on the result. This method is insecure because, as a client API, it is susceptible to tampering and therefore cheating to manipulate skill ratings.

A message of type MessageType.Matchmaking_ReportResultInsecure will be generated in response. First call Message.IsError() to check if any error has occurred. This response has no payload. If no error has occurred, the request is successful.

◆ GetStats()

static Task< MatchmakingStats > GetStats ( string  pool,
uint  maxLevel,
MatchmakingStatApproach  approach = MatchmakingStatApproach.Trailing 
)
inlinestatic

Gets the matchmaking statistics for the current user.

Note
Applicable to the following matchmaking modes: Quickmatch, Browse
Parameters
poolThe pool to look in.
maxLevel(beta feature, don't use it)
approach(beta feature, don't use it)
Returns

Request information of type Task, including the request ID, and its response message will contain data of type MatchmakingStats.

Error Code Error Message
3006201 match enqueue: invalid pool name
3006208 match enqueue: no skill

When given a pool, the system will look up the current user's wins, losses, draws and skill level. The skill level returned will be between 1 and the maximum level. The approach will determine how should the skill level rise toward the maximum level.

A message of type MessageType.Matchmaking_GetStats will be generated in response. First call Message.IsError() to check if any error has occurred. If no error has occurred, the message will contain a payload of type MatchmakingStats. Extract the payload from the message handle with message.Data.

◆ Browse2()

static Task< MatchmakingBrowseResult > Browse2 ( string  pool,
MatchmakingOptions  matchmakingOptions = null 
)
inlinestatic

Gets rooms by matchmakinging pool name. The user can join the room with RoomService.Join2 toor cancel the retrieval with MatchmakingService.Cancel.

Note
Applicable to the following matchmaking mode: Browse
Parameters
poolThe matchmaking pool name you want to browse.
matchmakingOptions(Optional) The matchmaking configuration of the browse request.
Returns

Request information of type Task, including the request ID, and its response message will contain data of type MatchmakingBrowseResult.

Error Code Error Message
3006201 match enqueue: invalid pool name
3006205 match browse: access denied
3006207 match enqueue: invalid query key

A message of type MessageType.Matchmaking_Browse2 will be generated in response. First call Message.IsError() to check if any error has occurred. If no error has occurred, the message will contain a payload of type MatchmakingBrowseResult. Extract the payload from the message handle with message.Data.

◆ Browse2ForCustomPage()

static Task< MatchmakingBrowseResult > Browse2ForCustomPage ( string  pool,
MatchmakingOptions  matchmakingOptions = null,
int  pageIndex = 0,
int  pageSize = 5 
)
inlinestatic

Gets rooms by matchmakinging pool name and specify the page number and the number of pages per page.

Parameters
poolThe matchmaking pool name you want to browse.
matchmakingOptions(Optional) The matchmaking configuration of the browse request.
pageIndex(Optional)Start page index.
pageSize(Optional)the number of pages per page.
Returns

Request information of type Task, including the request ID, and its response message will contain data of type MatchmakingBrowseResult.

A message of type MessageType.Matchmaking_Browse2CustomPage will be generated in response. First call Message.IsError() to check if any error has occurred. If no error has occurred, the message will contain a payload of type MatchmakingBrowseResult. Extract the payload from the message handle with message.Data.

◆ Cancel()

static Task Cancel ( )
inlinestatic

Cancels a matchmaking request. Call this function to cancel an enqueue request before a match is made. This is typically triggered when a user gives up waiting. If you do not cancel the request but the user goes offline, the user/room will be timed out according to the setting of reserved period on the PICO Developer Platform.

Note
Applicable to the following matchmaking modes: Quickmatch, Browse
Returns

Request information of type Task, including the request ID, and its response message does not contain data.

Error Code Error Message
3006201 match enqueue: invalid pool name
3006206 match cancel: not in match
3006301 server error: unknown

A message of type MessageType.Matchmaking_Cancel2 will be generated in response. Call Message.IsError() to check if any error has occurred. This response has no payload. If no error has occurred, the request is successful.

◆ CreateAndEnqueueRoom2()

static Task< MatchmakingEnqueueResultAndRoom > CreateAndEnqueueRoom2 ( string  pool,
MatchmakingOptions  matchmakingOptions = null 
)
inlinestatic

Creates a matchmaking room, then enqueues and joins it.

Note
Applicable to the following matchmaking modes: Quickmatch, Browse, Advanced (Can Users Create Rooms=true)
Parameters
poolThe matchmaking pool to use, which is created on the PICO Developer Platform.
matchmakingOptions(Optional) Additional matchmaking configuration for this request.
Returns

Request information of type Task, including the request ID, and its response message will contain data of type MatchmakingEnqueueResultAndRoom.

Error Code Error Message
3006201 match enqueue: invalid pool name
3006203 match create room: pool config not allow user create room
3006207 match enqueue: invalid query key
3006301 server error: unknown
3006204 match enqueue: invalid room id(Assigned room id, present in this context, indicates an internal server error)
3006103 invalid room(The room was found to be invalid when joining the room, which appears in this context, indicating an internal server error)
3006102 duplicate join room(Duplicate joins are found when joining a room, which appears in this context, indicating an internal server error)
3006106 exceed max room player number(Exceeding the maximum number of people when joining a room, appears in this context, indicating an internal server error)
3006105 illegal enter request(Illegal incoming requests, such as not in the allowed whitelist, appear in this context, indicating an internal server error)
3006108 room is locked(When joining a room, it is found that the room is locked, appears in this context, indicating an internal server error)

A message of type MessageType.Matchmaking_CreateAndEnqueueRoom2 will be generated in response. First call message.IsError() to check if any error has occurred. If no error has occurred, the message will contain a payload of type MatchmakingEnqueueResultAndRoom. Extract the payload from the message handle with message.Data.

◆ Enqueue2()

static Task< MatchmakingEnqueueResult > Enqueue2 ( string  pool,
MatchmakingOptions  matchmakingOptions = null 
)
inlinestatic

Enqueues for an available matchmaking room to join. When the server finds a match, it will return a message of type MessageType.Notification_Matchmaking_MatchFound. You can join found matching rooms by calling RoomService.Join2. If you want to cancel the match early, you can use MatchmakingService.Cancel.

Note
Applicable to the following matchmaking mode: Quickmatch
Parameters
poolThe matchmaking pool to use, which is defined on the PICO Developer Platform.
matchmakingOptions(Optional) Match configuration for Enqueue.
Returns

Request information of type Task, including the request ID, and its response message will contain data of type MatchmakingEnqueueResult.

Error Code Error Message
3006201 match enqueue: invalid pool name
3006401 logic state checking failed
3006207 match enqueue: invalid query key
3006301 server error: unknown

A message of type MessageType.Matchmaking_Enqueue2 will be generated in response. First call message.IsError() to check if any error has occurred. If no error has occurred, the message will contain a payload of type MatchmakingEnqueueResult. Extract the payload from the message handle with message.Data.

◆ GetAdminSnapshot()

static Task< MatchmakingAdminSnapshot > GetAdminSnapshot ( )
inlinestatic

Debugs the state of the current matchmaking pool queue.

Note
  • This function should not be used in production.
  • Applicable to the following matchmaking modes: Quickmatch, Browse
Returns

Request information of type Task, including the request ID, and its response message will contain data of type MatchmakingAdminSnapshot.

Error Code Error Message
3006201 match enqueue: invalid pool name
3006301 server error: unknown

A message of type MessageType.Matchmaking_GetAdminSnapshot will be generated in response. First call message.IsError() to check if any error has occurred. If no error has occurred, the message will contain a payload of type MatchmakingAdminSnapshot. Extract the payload from the message handle with message.Data.

◆ StartMatch()

static Task StartMatch ( UInt64  roomId)
inlinestatic

Reports that a skill-rating match has started. You can use this method after joining the room.

Note
  • This function is only for pools with skill-based matching.
  • Applicable to the following matchmaking modes: Quickmatch, Browse (+ Skill Pool)
Parameters
roomIdThe ID of the room you want to match.
Returns

Request information of type Task, including the request ID, and its response message does not contain data.

A message of type MessageType.Matchmaking_StartMatch will be generated in response. Call message.IsError() to check if any error has occurred.

◆ SetMatchFoundNotificationCallback()

static void SetMatchFoundNotificationCallback ( Message< Room >.Handler  handler)
inlinestatic

Sets the callback to get notified when a match has been found. For example, after calling MatchmakingService.Enqueue, when the match is successful, you will receive Notification_Matchmaking_MatchFound, and then execute the processing function set by this function.

Parameters
handlerThe callback function will be called when receiving the Notification_Matchmaking_MatchFound message.

◆ SetCancel2NotificationCallback()

static void SetCancel2NotificationCallback ( Message.Handler  handler)
inlinestatic

A notification will be sent to the player after they have been kicked out of the matchmaking pool. Listen to the event to receive a message.

Parameters
handlerThe callback function will be called when receiving the Matchmaking_Cancel2 message and the value of requestID is 0.