public static final class

RoomConfig.Builder

extends Object
java.lang.Object
   ↳ com.google.android.gms.games.multiplayer.realtime.RoomConfig.Builder

Class Overview

Builder class for RoomConfig.

Summary

Public Methods
RoomConfig.Builder addPlayersToInvite(String... playerIds)
Add one or more player IDs to invite to the room.
RoomConfig.Builder addPlayersToInvite(ArrayList<String> playerIds)
Add a list of player IDs to invite to the room.
RoomConfig build()
Builds a new RoomConfig object.
RoomConfig.Builder setAutoMatchCriteria(Bundle autoMatchCriteria)
Sets the auto-match criteria for the room.
RoomConfig.Builder setInvitationIdToAccept(String invitationId)
Set the ID of the invitation to accept.
RoomConfig.Builder setMessageReceivedListener(RealTimeMessageReceivedListener listener)
Set the listener for message received from a connected peer in a room.
RoomConfig.Builder setRoomStatusUpdateListener(RoomStatusUpdateListener listener)
Set the listener for room status changes.
RoomConfig.Builder setSocketCommunicationEnabled(boolean enableSockets)
Sets whether to enable sockets for sending and receiving data.
RoomConfig.Builder setVariant(int variant)
Sets the variant for the room when calling createRoom(RoomConfig).
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public RoomConfig.Builder addPlayersToInvite (String... playerIds)

Add one or more player IDs to invite to the room. This should be set only when calling createRoom(RoomConfig)

Parameters
playerIds One or more player IDs to invite to the room.
Returns
  • The builder instance.

public RoomConfig.Builder addPlayersToInvite (ArrayList<String> playerIds)

Add a list of player IDs to invite to the room. This should be set only when calling createRoom(RoomConfig)

Parameters
playerIds One or more player IDs to invite to the room.
Returns
  • The builder instance.

public RoomConfig build ()

Builds a new RoomConfig object.

Returns

public RoomConfig.Builder setAutoMatchCriteria (Bundle autoMatchCriteria)

Sets the auto-match criteria for the room. See createAutoMatchCriteria(int, int, long).

Parameters
autoMatchCriteria The criteria for auto-matching one or more players for the match. If null, the match is created with the invited players only.
Returns
  • The builder instance.

public RoomConfig.Builder setInvitationIdToAccept (String invitationId)

Set the ID of the invitation to accept. This is required and should be set only when calling joinRoom(RoomConfig).

Parameters
invitationId The ID of the invitation to accept.

public RoomConfig.Builder setMessageReceivedListener (RealTimeMessageReceivedListener listener)

Set the listener for message received from a connected peer in a room.

If not using socket-based communication, a non-null listener must be provided here before constructing the RoomConfig object.

Parameters
listener The message received listener that is called to notify the client when it receives a message in a room. The listener is called on the main thread.

public RoomConfig.Builder setRoomStatusUpdateListener (RoomStatusUpdateListener listener)

Set the listener for room status changes.

Parameters
listener The listener that is called to notify the client when the status of the room has changed. The listener is called on the main thread.

public RoomConfig.Builder setSocketCommunicationEnabled (boolean enableSockets)

Sets whether to enable sockets for sending and receiving data. The socket for each participant can be obtained using getRealTimeSocketForParticipant(String, String). If false the sendUnreliableRealTimeMessage(byte[], String, String) API should be used to send messages.

Note that for reliable messages, the sendReliableRealTimeMessage(RealTimeReliableMessageSentListener, byte[], String, String) API should still be used. Reliable messages will be delivered via the RealTimeMessageReceivedListener registered with setMessageReceivedListener(RealTimeMessageReceivedListener).

Parameters
enableSockets Whether to enable the use of sockets for sending/receiving data.
Returns
  • The builder instance.

public RoomConfig.Builder setVariant (int variant)

Sets the variant for the room when calling createRoom(RoomConfig). This is an optional, developer-controlled parameter describing the type of game to play, and is used for auto-matching criteria. Must be either a positive integer or ROOM_VARIANT_ANY (the default) if not desired.

Parameters
variant The variant for the match.
Returns
  • The builder instance.