Skip to content

Commit 6304de3

Browse files
Merge branch 'develop' into fix/replace-null-coalescence-operators
2 parents 5cc488b + ba02e05 commit 6304de3

File tree

16 files changed

+114
-179
lines changed

16 files changed

+114
-179
lines changed

Assets/Scripts/ApplicationLifecycle/ApplicationController.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,17 @@
1717

1818
namespace Unity.BossRoom.ApplicationLifecycle
1919
{
20-
2120
/// <summary>
2221
/// An entry point to the application, where we bind all the common dependencies to the root DI scope.
2322
/// </summary>
2423
public class ApplicationController : LifetimeScope
2524
{
26-
[SerializeField] UpdateRunner m_UpdateRunner;
27-
[SerializeField] ConnectionManager m_ConnectionManager;
28-
[SerializeField] NetworkManager m_NetworkManager;
25+
[SerializeField]
26+
UpdateRunner m_UpdateRunner;
27+
[SerializeField]
28+
ConnectionManager m_ConnectionManager;
29+
[SerializeField]
30+
NetworkManager m_NetworkManager;
2931

3032
LocalLobby m_LocalLobby;
3133
LobbyServiceFacade m_LobbyServiceFacade;
@@ -124,17 +126,21 @@ private IEnumerator LeaveBeforeQuit()
124126
{
125127
Debug.LogError(e.Message);
126128
}
129+
127130
yield return null;
128131
Application.Quit();
129132
}
130133

131134
private bool OnWantToQuit()
132135
{
136+
Application.wantsToQuit -= OnWantToQuit;
137+
133138
var canQuit = m_LocalLobby != null && string.IsNullOrEmpty(m_LocalLobby.LobbyID);
134139
if (!canQuit)
135140
{
136141
StartCoroutine(LeaveBeforeQuit());
137142
}
143+
138144
return canQuit;
139145
}
140146

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
@@ -141,7 +141,7 @@ public override void ApprovalCheck(NetworkManager.ConnectionApprovalRequest requ
141141
response.Reason = JsonUtility.ToJson(gameReturnStatus);
142142
if (m_LobbyServiceFacade.CurrentUnityLobby != null)
143143
{
144-
m_LobbyServiceFacade.RemovePlayerFromLobbyAsync(connectionPayload.playerId, m_LobbyServiceFacade.CurrentUnityLobby.Id);
144+
m_LobbyServiceFacade.RemovePlayerFromLobbyAsync(connectionPayload.playerId);
145145
}
146146
}
147147

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)