RoomConfig.Builder | Android Developers

Quicknav Quicknav
Links

- Google Play Developer Console
- Android Developers Blog
- About Android

Android Sites

- Android.com
- Android Developers
- Android Open Source Project

Language
close

- - About
  - Wear
  - TV
  - Auto
- - Get Started
  - Devices
  - Style
  - Patterns
  - Building Blocks
  - Downloads
  - Videos
- - Training
  - API Guides
  - Reference
  - Tools
  - Google Services
  - Samples
- - Google Play
  - Essentials
  - Get Users
  - Engage & Retain
  - Monetize
  - Tools & Reference
  - Developer Stories

## Results

Loading...
Summary: Methods | Inherited Methods | [Expand All]
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 `create(GoogleApiClient, RoomConfig)`.

[Expand] Inherited Methods
From class java.lang.Object
Object | clone()
boolean | equals(Object arg0)
void | finalize()
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)

## 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 `create(GoogleApiClient, 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 `create(GoogleApiClient, 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

- The built `RoomConfig` instance.

#### 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 `join(GoogleApiClient, 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 `getSocketForParticipant(GoogleApiClient, String, String)`. If false the `sendUnreliableMessage(GoogleApiClient, byte[], String, String)` API should be used to send messages.

Note that for reliable messages, the `sendReliableMessage(GoogleApiClient, ReliableMessageSentCallback, 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 `create(GoogleApiClient, 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_DEFAULT` (the default) if not desired.

Note that variants must match exactly. Thus, if you do not specify a variant, only other rooms created with `ROOM_VARIANT_DEFAULT` will be considered potential auto-matches.

##### Parameters

variant | The variant for the match.

##### Returns

- The builder instance.