# Upgrade 1.8 -> 2.0

## <mark style="color:yellow;">Obsolete:</mark> MatchmakerClient

Starting from 2.0, the old MatchmakerClient cloud service has been marked as obsolete. [Lobbies](https://docs.coherence.io/hosting/coherence-cloud/game-services/lobbies) should be used for matchmaking instead.

## Cloud Service Accessor Migration

Accessors for some cloud services were migrated from **CloudService.GameServices** directly to the root of **CloudService**.

Additionally, **LobbiesService** can now be accessed directly from the **CloudService** root as well, instead of being found under **CloudService.Rooms**.

This should help make your code shorter and make it easier to find all the different cloud services.

```csharp
async void Start()
{
    PlayerAccount playerAccount = await PlayerAccount.GetMainAsync();

    //var lobbies = playerAccount.Services.Rooms.LobbyService; // <- old
    var lobbies = playerAccount.Services.Lobbies;              // <- new

    var lobbySessions = await lobbies.GetLobbySessionsAsync();
    Debug.Log($"You are currently in {lobbySessions.Count} lobbies.");

    //var cloudStorage = playerAccount.Services.GameServices.CloudStorage; // <- old
    var cloudStorage = playerAccount.Services.CloudStorage;                // <- new

    var storageId = (playerAccount.Id.ToString(), "Friends");
    string[] friends = await cloudStorage.LoadObjectAsync<string[]>(storageId);
    Debug.Log($"You have {friends.Length} friends: {string.Join(", ", friends)}.");
}
```

## CloudService.Regions

Functionality related to regions was relocated from CloudService.Rooms to CloudService.Regions.

This makes more sense when using regions without rooms, such as when working with worlds.

```csharp
async void Start()
{
    PlayerAccount playerAccount = await PlayerAccount.GetMainAsync();

    //var roomsService = playerAccount.Services.Rooms;
    //var regions = await roomsService.RefreshRegionsAsync(); // <- old
    var regionsService = playerAccount.Services.Regions;
    var regions = await regionsService.FetchRegionsAsync();   // <- new

    Debug.Log($"Project has {regions.Length} regions: {string.Join(", ", regions)}.");
}
```

## Lobby Creation

Some changes were made to the [Lobby](https://docs.coherence.io/hosting/coherence-cloud/coherence-cloud-apis/lobbies) creation process, to clearly distinguish between Lobbies that are associated with a particular Room, and Lobbies that are not associated with any Room (Lobbies for interroom communication).

### For Room

The new **CreateLobbyOptions.ForRoom** method can be used to initialize new instances of lobby creation options that should be associated with a particular room:

```csharp
async void Start()
{
    PlayerAccount playerAccount = await PlayerAccount.GetMainAsync();
    var regionsService = playerAccount.Services.Regions;
    var lobbies = playerAccount.Services.Lobbies;
    var regions = await regionsService.FetchRegionsAsync();
    var region = regions.First();

    var rooms  = playerAccount.Services.Rooms;
    var roomsService = rooms.GetRoomServiceForRegion(region);
    var room = await roomsService.CreateRoomAsync(new() { Name = "My Room" });

    var createLobbyOptions = CreateLobbyOptions.ForRoom(room);
    var lobbySession = await lobbies.CreateLobbyAsync(createLobbyOptions);

    Debug.Log($"You created the lobby '{lobbySession.LobbyData.Name}'.");
}
```

### Not For Room

To create a lobby that is not associated with any particular room, use the CreateLobbyOptions's constructor instead:

```csharp
async void Start()
{
    PlayerAccount playerAccount = await PlayerAccount.GetMainAsync();
    var regionsService = playerAccount.Services.Regions;
    var lobbies = playerAccount.Services.Lobbies; // <- new
    var regions = await regionsService.FetchRegionsAsync();
    var region = regions.First();

    var createLobbyOptions = new CreateLobbyOptions(name: "My Lobby", region, maxPlayers: 25);
    var lobbySession = await lobbies.CreateLobbyAsync(createLobbyOptions);

    Debug.Log($"You created the lobby '{lobbySession.LobbyData.Name}'.");
}
```

## CreateLobbyOptions.Secret → Password

The **Secret** property on the **CreateLobbyOptions** type has been marked as obsolete, and replaced by a **Password** property.

This was done to avoid potential confusion between a room secret and a lobby password, which are two separate things.

## RefreshRegions → RefreshRegionsInfo

The regions API now returns not only a list regions but also a list of ping servers for use with the new [Ping Client](https://docs.coherence.io/hosting/coherence-cloud/coherence-cloud-apis/ping-client). Following functions have been renamed:

```
cloudRooms.Regions -> cloudRooms.RegionsInfo

cloudRooms.RefreshRegions -> cloudRooms.RefreshRegionsInfo

cloudRooms.RefreshRegionsAsync -> cloudRooms.RefreshRegionsInfoAsync

roomRegionsService.Regions -> roomRegionsService.RegionsInfo

roomRegionsService.FetchRegions -> roomRegionsService.FetchRegionsInfo

roomRegionsService.FetchRegionsAsync -> roomRegionsService.FetchRegionsInfoAsync
```
