Skip to content

Commit 34a13bf

Browse files
committed
code formatting, better naming
1 parent a135e20 commit 34a13bf

File tree

3 files changed

+47
-48
lines changed

3 files changed

+47
-48
lines changed

Assets/BossRoom/Scripts/Client/UI/UIServices.cs

Lines changed: 0 additions & 48 deletions
This file was deleted.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using System;
2+
using Unity.Multiplayer.Samples.BossRoom.Client;
3+
using Unity.Multiplayer.Samples.BossRoom.Shared.Infrastructure;
4+
using Unity.Multiplayer.Samples.BossRoom.Shared.Net.UnityServices.Infrastructure;
5+
using Unity.Services.Lobbies;
6+
using UnityEngine;
7+
8+
namespace Unity.Multiplayer.Samples.BossRoom.Visual
9+
{
10+
public class UnityServicesUIHandler : MonoBehaviour
11+
{
12+
IDisposable m_Subscriptions;
13+
14+
void Awake()
15+
{
16+
DontDestroyOnLoad(gameObject);
17+
}
18+
19+
[Inject]
20+
void Initialize(ISubscriber<UnityServiceErrorMessage> serviceError)
21+
{
22+
m_Subscriptions = serviceError.Subscribe(ServiceErrorHandler);
23+
}
24+
25+
void ServiceErrorHandler(UnityServiceErrorMessage error)
26+
{
27+
var errorMessage = error.Message;
28+
if (error.AffectedService == UnityServiceErrorMessage.Service.Lobby)
29+
{
30+
if ((error.OriginalException as LobbyServiceException).Reason == LobbyExceptionReason.LobbyConflict)
31+
{
32+
// LobbyConflict can have multiple causes. Let's add other solutions here if there's other situations that arise for this.
33+
errorMessage += "\nSee logs for possible causes and solution.";
34+
Debug.LogError($"Got service error {error.Message} with LobbyConflict. Possible conflict cause: Trying to play with two builds on the " +
35+
$"same machine. Please use command line arg '{ClientMainMenuState.AuthProfileCommandLineArg} someName' to set a different auth profile.\n");
36+
}
37+
}
38+
39+
PopupPanel.ShowPopupPanel("Service error", errorMessage);
40+
}
41+
42+
void OnDestroy()
43+
{
44+
m_Subscriptions.Dispose();
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)