Skip to content

Commit 774b3f8

Browse files
feat: upgrade to lobby 1.1.0 [MTT-7092] [MTT-5665] [MTT-7101] [MTT-5708] (#860)
* updating to lobby 1.1.0 * locking lobby at creation to prevent other players from joining before it is ready * removing explicit reference to wire in package manifest * removing unnecessary periodic lobby updates * removing old exception catch that is no longer necessary and adding new temporary catch for edge case exception
1 parent c661768 commit 774b3f8

File tree

11 files changed

+81
-165
lines changed

11 files changed

+81
-165
lines changed

Assets/Scripts/ConnectionManagement/ConnectionMethod.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ protected void SetConnectionPayload(string playerId, string playerName)
6666
m_ConnectionManager.NetworkManager.NetworkConfig.ConnectionData = payloadBytes;
6767
}
6868

69-
/// Using authentication, this makes sure your session is associated with your account and not your device. This means you could reconnect
70-
/// from a different device for example. A playerId is also a bit more permanent than player prefs. In a browser for example,
69+
/// Using authentication, this makes sure your session is associated with your account and not your device. This means you could reconnect
70+
/// from a different device for example. A playerId is also a bit more permanent than player prefs. In a browser for example,
7171
/// player prefs can be cleared as easily as cookies.
72-
/// The forked flow here is for debug purposes and to make UGS optional in Boss Room. This way you can study the sample without
73-
/// setting up a UGS account. It's recommended to investigate your own initialization and IsSigned flows to see if you need
72+
/// The forked flow here is for debug purposes and to make UGS optional in Boss Room. This way you can study the sample without
73+
/// setting up a UGS account. It's recommended to investigate your own initialization and IsSigned flows to see if you need
7474
/// those checks on your own and react accordingly. We offer here the option for offline access for debug purposes, but in your own game you
7575
/// might want to show an error popup and ask your player to connect to the internet.
7676
protected string GetPlayerId()
@@ -156,7 +156,7 @@ public override async Task SetupClientConnectionAsync()
156156
$"host: {joinedAllocation.HostConnectionData[0]} {joinedAllocation.HostConnectionData[1]}, " +
157157
$"client: {joinedAllocation.AllocationId}");
158158

159-
await m_LobbyServiceFacade.UpdatePlayerRelayInfoAsync(joinedAllocation.AllocationId.ToString(), m_LocalLobby.RelayJoinCode);
159+
await m_LobbyServiceFacade.UpdatePlayerDataAsync(joinedAllocation.AllocationId.ToString(), m_LocalLobby.RelayJoinCode);
160160

161161
// Configure UTP with allocation
162162
var utp = (UnityTransport)m_ConnectionManager.NetworkManager.NetworkConfig.NetworkTransport;
@@ -197,13 +197,15 @@ public override async Task SetupHostConnectionAsync()
197197

198198
m_LocalLobby.RelayJoinCode = joinCode;
199199

200-
//next line enable lobby and relay services integration
201-
await m_LobbyServiceFacade.UpdateLobbyDataAsync(m_LocalLobby.GetDataForUnityServices());
202-
await m_LobbyServiceFacade.UpdatePlayerRelayInfoAsync(hostAllocation.AllocationIdBytes.ToString(), joinCode);
200+
// next line enables lobby and relay services integration
201+
await m_LobbyServiceFacade.UpdateLobbyDataAndUnlockAsync();
202+
await m_LobbyServiceFacade.UpdatePlayerDataAsync(hostAllocation.AllocationIdBytes.ToString(), joinCode);
203203

204204
// Setup UTP with relay connection info
205205
var utp = (UnityTransport)m_ConnectionManager.NetworkManager.NetworkConfig.NetworkTransport;
206206
utp.SetRelayServerData(new RelayServerData(hostAllocation, k_DtlsConnType)); // This is with DTLS enabled for a secure connection
207+
208+
Debug.Log($"Created relay allocation with join code {m_LocalLobby.RelayJoinCode}");
207209
}
208210
}
209211
}

Assets/Scripts/ConnectionManagement/ConnectionState/HostingState.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public override void ApprovalCheck(NetworkManager.ConnectionApprovalRequest requ
129129
response.Reason = JsonUtility.ToJson(gameReturnStatus);
130130
if (m_LobbyServiceFacade.CurrentUnityLobby != null)
131131
{
132-
m_LobbyServiceFacade.RemovePlayerFromLobbyAsync(connectionPayload.playerId, m_LobbyServiceFacade.CurrentUnityLobby.Id);
132+
m_LobbyServiceFacade.RemovePlayerFromLobbyAsync(connectionPayload.playerId);
133133
}
134134
}
135135

Assets/Scripts/ConnectionManagement/ConnectionState/StartingHostState.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ async void StartHost()
6868
try
6969
{
7070
await m_ConnectionMethod.SetupHostConnectionAsync();
71-
Debug.Log($"Created relay allocation with join code {m_LocalLobby.RelayJoinCode}");
7271

7372
// NGO's StartHost launches everything
7473
if (!m_ConnectionManager.NetworkManager.StartHost())

Assets/Scripts/UnityServices/Lobbies/JoinedLobbyContentHeartbeat.cs

Lines changed: 0 additions & 75 deletions
This file was deleted.

Assets/Scripts/UnityServices/Lobbies/JoinedLobbyContentHeartbeat.cs.meta

Lines changed: 0 additions & 11 deletions
This file was deleted.

Assets/Scripts/UnityServices/Lobbies/LobbyAPIInterface.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public async Task<Lobby> CreateLobby(string requesterUasId, string lobbyName, in
4242
CreateLobbyOptions createOptions = new CreateLobbyOptions
4343
{
4444
IsPrivate = isPrivate,
45+
IsLocked = true, // locking the lobby at creation to prevent other players from joining before it is ready
4546
Player = new Player(id: requesterUasId, data: hostUserData),
4647
Data = lobbyData
4748
};

0 commit comments

Comments
 (0)