PICO Platform Unity SDK
RoomService Class Reference

Static Public Member Functions

static RoomOptions GetCreatePrivateRoomOptions (Dictionary< string, string > dataStore)
 Gets the room options for create a private room. You can use it when you use RoomService.CreateAndJoinPrivate2. More...
 
static RoomOptions GetJoinOrCreateNamedRoomOptions (Dictionary< string, string > dataStore, string name, string password)
 Gets the room options for joining or creating a named room. You can use it when you use RoomService.JoinOrCreateNamedRoom. More...
 
static Task< RoomListGetNamedRooms (int pageIndex, int pageSize)
 Gets the list of named rooms created for the app. More...
 
static Task< RoomJoinOrCreateNamedRoom (RoomJoinPolicy joinPolicy, bool createIfNotExist, uint maxUsers, RoomOptions options)
 Join or create a named room. More...
 
static Task LaunchInvitableUserFlow (UInt64 roomID)
 Launches the invitation flow to let the current user invite friends to a specified room. This launches the system default invite UI where all of the user's friends are displayed. This is intended to be a shortcut for developers not wanting to build their own invite-friends UI. More...
 
static Task< RoomUpdateDataStore (UInt64 roomId, Dictionary< string, string > data)
 Updates the data store of the current room (the caller should be the room owner). More...
 
static Task< RoomCreateAndJoinPrivate2 (RoomJoinPolicy policy, uint maxUsers, RoomOptions roomOptions)
 Creates a new private room and joins it. More...
 
static Task< RoomGet (UInt64 roomId)
 Gets the information about a specified room. More...
 
static Task< RoomGetCurrent ()
 Gets the data of the room you are currently in. More...
 
static Task< RoomGetCurrentForUser (string userId)
 Gets the current room of the specified user. More...
 
static Task< UserListGetInvitableUsers2 (RoomOptions roomOptions=null)
 Gets a list of members the user can invite to the room. These members are drawn from the user's friends list and recently encountered list, and filtered based on relevance and interests. More...
 
static Task< RoomListGetModeratedRooms (int index, int size)
 Gets the list of moderated rooms created for the application. More...
 
static Task< RoomInviteUser (UInt64 roomId, string token)
 Invites a user to the current room. More...
 
static Task< RoomJoin2 (UInt64 roomId, RoomOptions options)
 Joins the target room and meanwhile leaves the current room. More...
 
static Task< RoomKickUser (UInt64 roomId, string userId, int kickDuration)
 Kicks a user out of a room. For use by homeowners only. More...
 
static Task< RoomLeave (UInt64 roomId)
 Leaves the current room. More...
 
static Task< RoomSetDescription (UInt64 roomId, string description)
 Sets the description of a room. For use by homeowners only. More...
 
static Task< RoomUpdateMembershipLockStatus (UInt64 roomId, RoomMembershipLockStatus membershipLockStatus)
 Locks/unlocks the membership of a room (the caller should be the room owner) to allow/disallow new members from being able to join the room. More...
 
static Task UpdateOwner (UInt64 roomId, string userId)
 Modifies the owner of the room, this person needs to be the person in this room. More...
 
static Task< RoomUpdatePrivateRoomJoinPolicy (UInt64 roomId, RoomJoinPolicy policy)
 Sets the join policy for a specified private room. More...
 
static void SetRoomInviteAcceptedNotificationCallback (Message< string >.Handler handler)
 Sets the callback to get notified when the user has accepted an invitation. More...
 
static void SetUpdateNotificationCallback (Message< Room >.Handler handler)
 Sets the callback to get notified when the current room has been updated. Use Message.Data to extract the room. More...
 
static void SetKickUserNotificationCallback (Message< Room >.Handler handler)
 Sets the callback to get notified when the user has been kicked out of a room. Listen to this event to receive a relevant message. Use Message.Data to extract the room. More...
 
static void SetSetDescriptionNotificationCallback (Message< Room >.Handler handler)
 Sets the callback to get notified when the room description has been updated. Listen to this event to receive a relevant message. Use Message.Data to extract the room. More...
 
static void SetUpdateDataStoreNotificationCallback (Message< Room >.Handler handler)
 Sets the callback to get notified when the room data has been modified. Listen to this event to receive a relevant message. Use Message.Data to extract the room. More...
 
static void SetLeaveNotificationCallback (Message< Room >.Handler handler)
 If a player is passively removed from a room (for example, if they initiate another match within the room and are subsequently removed by the system or if they are kicked out of the room), they will receive a notification. Listen to this event to receive a relevant message. Use Message.Data to extract the room. More...
 
static void SetJoin2NotificationCallback (Message< Room >.Handler handler)
 If a player comes across network or disaster recovery problems after joining a room, they may not receive a notification confirming that they've successfully entered the room. In such cases, the server will resend the notification to ensure that the user receives it. Use Message.Data to extract the room. More...
 
static void SetUpdateOwnerNotificationCallback (Message.Handler handler)
 When there is a change in the room owner, the new owner will receive a notification. Listen to this event to receive a relevant message. Use Message.Data to extract the room. More...
 
static void SetUpdateMembershipLockStatusNotificationCallback (Message< Room >.Handler handler)
 Sets the callback to get notified when the membership status of a room has been changed. Listen to this event to receive a relevant message. Use Message.Data to extract the room. More...
 

Member Function Documentation

◆ GetCreatePrivateRoomOptions()

static RoomOptions GetCreatePrivateRoomOptions ( Dictionary< string, string >  dataStore)
inlinestatic

Gets the room options for create a private room. You can use it when you use RoomService.CreateAndJoinPrivate2.

Parameters
dataStoreThe key/value pairs to add.
Returns
The room options for create a private room.

◆ GetJoinOrCreateNamedRoomOptions()

static RoomOptions GetJoinOrCreateNamedRoomOptions ( Dictionary< string, string >  dataStore,
string  name,
string  password 
)
inlinestatic

Gets the room options for joining or creating a named room. You can use it when you use RoomService.JoinOrCreateNamedRoom.

Parameters
dataStoreThe key/value pairs to add.
nameThe name of the named room.
passwordThe password of the named room.
Returns
The room options for joining or creating a named room.

◆ GetNamedRooms()

static Task< RoomList > GetNamedRooms ( int  pageIndex,
int  pageSize 
)
inlinestatic

Gets the list of named rooms created for the app.

Parameters
pageIndexDefines which page of entries to return. The index for the first page is 0.
pageSizeThe number of entries returned on each page. Value range: [5,20].
Returns

The request ID of this async function.

A message of type MessageType.Room_GetNamedRooms 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 RoomList. Extract the payload from the message handle with Message.Data.

◆ JoinOrCreateNamedRoom()

static Task< Room > JoinOrCreateNamedRoom ( RoomJoinPolicy  joinPolicy,
bool  createIfNotExist,
uint  maxUsers,
RoomOptions  options 
)
inlinestatic

Join or create a named room.

Parameters
joinPolicyThe join policy of the room. Currently only support 'RoomJoinPolicy Everyone'.
createIfNotExistDetermines whether to create a new room if the named room does not exist:
  • true: create
  • false: do not create
maxUsersThe maximum number of users allowed in the room, including the creator.
optionsAdditional room configuration for this request.
Returns

The request ID of this async function.

A message of type MessageType.Room_JoinNamed 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 Room. Extract the payload from the message handle with Message.Data.

◆ LaunchInvitableUserFlow()

static Task LaunchInvitableUserFlow ( UInt64  roomID)
inlinestatic

Launches the invitation flow to let the current user invite friends to a specified room. This launches the system default invite UI where all of the user's friends are displayed. This is intended to be a shortcut for developers not wanting to build their own invite-friends UI.

Parameters
roomIDThe ID of the room.
Returns
The request ID of this async function. A message of type MessageType.Room_LaunchInvitableUserFlow will be generated in response. Call message.IsError() to check if any error has occurred.

◆ UpdateDataStore()

static Task< Room > UpdateDataStore ( UInt64  roomId,
Dictionary< string, string >  data 
)
inlinestatic

Updates the data store of the current room (the caller should be the room owner).

Note
Room data stores only allow string values. The maximum key length is 32 bytes and the maximum value length is 64 bytes. If you provide illegal values, this method will return an error.
Parameters
roomIdThe ID of the room that you currently own (call Room.OwnerOptional to check).
dataThe key/value pairs to add or update. Null value will clear a given key.
Returns

The request ID of this async function.

Error Code Error Message
3006004 change datastore failed: need room owner

A message of type MessageType.Room_UpdateDataStore 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 Room. Extract the payload from the message handle with Message.Data.

◆ CreateAndJoinPrivate2()

static Task< Room > CreateAndJoinPrivate2 ( RoomJoinPolicy  policy,
uint  maxUsers,
RoomOptions  roomOptions 
)
inlinestatic

Creates a new private room and joins it.

Note
This type of room can be obtained by querying the room where a friend is, so it is suitable for playing with friends.
Parameters
policySpecifies who can join the room:
  • 0: nobody
  • 1: everybody
  • 2: friends of members
  • 3: friends of the room owner
  • 4: invited users
  • 5: unknown
maxUsersThe maximum number of members allowed in the room, including the room creator.
roomOptionsRoom configuration for this request.
Returns

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

Error Code Error Message
3006101 room create: unknown error
3006114 setting of 'room max user' is too large

A message of type MessageType.Room_CreateAndJoinPrivate2 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 Room. Extract the payload from the message handle with message.Data.

◆ Get()

static Task< Room > Get ( UInt64  roomId)
inlinestatic

Gets the information about a specified room.

Parameters
roomIdThe ID of the room to get information for.
Returns

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

Error Code Error Message
3006103 invalid room
3006301 server error: unknown

A message of type MessageType.Room_Get 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 Room. Extract the payload from the message handle with message.Data.

◆ GetCurrent()

static Task< Room > GetCurrent ( )
inlinestatic

Gets the data of the room you are currently in.

Returns

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

Error Code Error Message
3006104 not in room

A message of type MessageType.Room_GetCurrent 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 with of type Room. Extract the payload from the message handle with message.Data.

◆ GetCurrentForUser()

static Task< Room > GetCurrentForUser ( string  userId)
inlinestatic

Gets the current room of the specified user.

Note
The user's privacy settings may not allow you to access their room.
Parameters
userIdThe ID of the user.
Returns

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

Error Code Error Message
3006104 not in room
3006009 tgt player is not in game now
3006301 server error: unknown

A message of type MessageType.Room_GetCurrentForUser 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 Room. Extract the payload from the message handle with message.Data.

◆ GetInvitableUsers2()

static Task< UserList > GetInvitableUsers2 ( RoomOptions  roomOptions = null)
inlinestatic

Gets a list of members the user can invite to the room. These members are drawn from the user's friends list and recently encountered list, and filtered based on relevance and interests.

Parameters
roomOptionsAdditional configuration for this request. If you pass null, the response will return code 0.
Returns

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

A message of type MessageType.Room_GetInvitableUsers2 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 UserList. Extract the payload from the message handle with message.Data.

◆ GetModeratedRooms()

static Task< RoomList > GetModeratedRooms ( int  index,
int  size 
)
inlinestatic

Gets the list of moderated rooms created for the application.

Parameters
indexStart page index.
sizePage entry number in response (should range from 5 to 20).
Returns

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

Error Code Error Message
3006301 server error: unknown

A message of type MessageType.Room_GetModeratedRooms 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 RoomList, the room info does not contain the UserList info. Extract the payload from the message handle with message.Data.

◆ InviteUser()

static Task< Room > InviteUser ( UInt64  roomId,
string  token 
)
inlinestatic

Invites a user to the current room.

Note
The user invited will receive a notification of type MessageType.Notification_Room_InviteReceived.
Parameters
roomIdThe ID of the room.
tokenThe user's invitation token, which is returned by RoomService.GetInvitableUsers2().
Returns

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

A message of type MessageType.Room_InviteUser 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 Room. Extract the payload from the message handle with message.Data.

◆ Join2()

static Task< Room > Join2 ( UInt64  roomId,
RoomOptions  options 
)
inlinestatic

Joins the target room and meanwhile leaves the current room.

Parameters
roomIdThe ID of the room to join.
options(Optional) Additional room configuration for this request.
Returns

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

Error Code Error Message
3006401 logic state checking failed
3006103 invalid room
3006102 duplicate join room(regarded as normal entry)
3006106 exceed max room player number
3006105 illegal enter request(Players outside the legal list enter)
3006108 room is locked

A message of type MessageType.Room_Join2 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 Room. Extract the payload from the message handle with message.Data.

◆ KickUser()

static Task< Room > KickUser ( UInt64  roomId,
string  userId,
int  kickDuration 
)
inlinestatic

Kicks a user out of a room. For use by homeowners only.

Parameters
roomIdThe ID of the room.
userIdThe ID of the user to be kicked (cannot be yourself).
kickDurationThe Length of the ban (in seconds).
Returns

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

Error Code Error Message
3006006 kick user failed: need room owner
3006007 kick user failed: tgt user is not in the room
3006008 kick user failed: can not kick self

A message of type MessageType.Room_KickUser 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 Room. Extract the payload from the message handle with message.Data.

◆ Leave()

static Task< Room > Leave ( UInt64  roomId)
inlinestatic

Leaves the current room.

Note
The room you are now in will be returned if the request succeeds.
Parameters
roomIdThe ID of the room.
Returns

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

Error Code Error Message
3006401 logic state checking failed(e.g. not in the room)
3006301 server error: unknown

A message of type MessageType.Room_Leave 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 Room. Extract the payload from the message handle with message.Data.

◆ SetDescription()

static Task< Room > SetDescription ( UInt64  roomId,
string  description 
)
inlinestatic

Sets the description of a room. For use by homeowners only.

Parameters
roomIdThe ID of the room to set description for.
descriptionThe new description of the room.
Returns

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

Error Code Error Message
3006005 set description failed: need room owner

A message of type MessageType.Room_SetDescription 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 Room. Extract the payload from the message handle with message.Data.

◆ UpdateMembershipLockStatus()

static Task< Room > UpdateMembershipLockStatus ( UInt64  roomId,
RoomMembershipLockStatus  membershipLockStatus 
)
inlinestatic

Locks/unlocks the membership of a room (the caller should be the room owner) to allow/disallow new members from being able to join the room.

Note
Locking membership will prevent other users from joining the room through Join2(), invitations, etc. Users that are in the room at the time of lock will be able to rejoin.
Parameters
roomIdThe ID of the room to lock/unlock membership for.
membershipLockStatusThe new membership status to set for the room:
  • 0: Unknown
  • 1: lock
  • 2: unlock
Returns

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

Error Code Error Message
3006104 not in room
3006109 update membership lock: need room owner

A message of type MessageType.Room_UpdateMembershipLockStatus 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 Room Extract the payload from the message handle with message.Data.

◆ UpdateOwner()

static Task UpdateOwner ( UInt64  roomId,
string  userId 
)
inlinestatic

Modifies the owner of the room, this person needs to be the person in this room.

Parameters
roomIdThe ID of the room to change ownership for.
userIdThe ID of the new user to own the room. The new user must be in the same room.
Returns

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

Error Code Error Message
3006001 change owner failed: need room owner
3006003 change owner failed: duplicate setting
3006002 change owner failed: new owner not in this room

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

◆ UpdatePrivateRoomJoinPolicy()

static Task< Room > UpdatePrivateRoomJoinPolicy ( UInt64  roomId,
RoomJoinPolicy  policy 
)
inlinestatic

Sets the join policy for a specified private room.

Parameters
roomIdThe ID of the room you want to set join policy for.
policySpecifies who can join the room:
  • 0: nobody
  • 1: everybody
  • 2: friends of members
  • 3: friends of the room owner
  • 4: invited users
  • 5: unknown
Returns

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

Error Code Error Message
3006104 not in room
3006112 update room join policy: need room owner

A message of type MessageType.Room_UpdatePrivateRoomJoinPolicy 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 Room. Extract the payload from the message handle with message.Data.

◆ SetRoomInviteAcceptedNotificationCallback()

static void SetRoomInviteAcceptedNotificationCallback ( Message< string >.Handler  handler)
inlinestatic

Sets the callback to get notified when the user has accepted an invitation.

Note
You can get the RoomID by 'Message.Data'. Then you can call 'RoomService.Join2' to join it.
Parameters
handlerThe callback function will be called when receiving the Notification_Room_InviteAccepted message.

◆ SetUpdateNotificationCallback()

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

Sets the callback to get notified when the current room has been updated. Use Message.Data to extract the room.

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

◆ SetKickUserNotificationCallback()

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

Sets the callback to get notified when the user has been kicked out of a room. Listen to this event to receive a relevant message. Use Message.Data to extract the room.

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

◆ SetSetDescriptionNotificationCallback()

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

Sets the callback to get notified when the room description has been updated. Listen to this event to receive a relevant message. Use Message.Data to extract the room.

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

◆ SetUpdateDataStoreNotificationCallback()

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

Sets the callback to get notified when the room data has been modified. Listen to this event to receive a relevant message. Use Message.Data to extract the room.

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

◆ SetLeaveNotificationCallback()

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

If a player is passively removed from a room (for example, if they initiate another match within the room and are subsequently removed by the system or if they are kicked out of the room), they will receive a notification. Listen to this event to receive a relevant message. Use Message.Data to extract the room.

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

◆ SetJoin2NotificationCallback()

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

If a player comes across network or disaster recovery problems after joining a room, they may not receive a notification confirming that they've successfully entered the room. In such cases, the server will resend the notification to ensure that the user receives it. Use Message.Data to extract the room.

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

◆ SetUpdateOwnerNotificationCallback()

static void SetUpdateOwnerNotificationCallback ( Message.Handler  handler)
inlinestatic

When there is a change in the room owner, the new owner will receive a notification. Listen to this event to receive a relevant message. Use Message.Data to extract the room.

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

◆ SetUpdateMembershipLockStatusNotificationCallback()

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

Sets the callback to get notified when the membership status of a room has been changed. Listen to this event to receive a relevant message. Use Message.Data to extract the room.

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