Skip to content

Commit 96575b7

Browse files
committed
replacing abstract methods with empty virtual ones
1 parent 444f436 commit 96575b7

File tree

7 files changed

+48
-169
lines changed

7 files changed

+48
-169
lines changed

Assets/BossRoom/Scripts/Gameplay/ConnectionManagement/ConnectionManager.cs

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,6 @@
1515

1616
namespace Unity.Multiplayer.Samples.BossRoom
1717
{
18-
public abstract class ConnectionState
19-
{
20-
protected ConnectionManager m_ConnectionManager;
21-
22-
public ConnectionState(ConnectionManager connectionManager)
23-
{
24-
m_ConnectionManager = connectionManager;
25-
}
26-
27-
public abstract void OnClientConnected(ulong clientId);
28-
public abstract void OnClientDisconnect(ulong clientId);
29-
30-
public abstract void OnServerStarted();
31-
32-
public abstract void StartClientIP(string playerId, string playerName, string ipaddress, int port);
33-
34-
public abstract Task StartClientLobbyAsync(string playerName, string playerId, Action<string> onFailure);
35-
36-
public abstract bool StartHostIP(string playerId, string playerName, string ipaddress, int port);
37-
38-
public abstract Task StartHostLobbyAsync(string playerId, string playerName);
39-
40-
public abstract void OnUserRequestedShutdown();
41-
42-
public abstract void OnServerShutdown();
43-
44-
public abstract void ApprovalCheck(byte[] connectionData, ulong clientId, NetworkManager.ConnectionApprovedDelegate connectionApprovedCallback);
45-
}
46-
4718
public enum ConnectionStateType
4819
{
4920
Offline,
@@ -203,7 +174,7 @@ public void OnServerShutdown()
203174
m_Logics[m_CurrentState].OnServerShutdown();
204175
}
205176

206-
void OnClientStarted()
177+
public void OnClientStarted()
207178
{
208179
// should only do this once StartClient has been called (start client will initialize NetworkSceneManager and CustomMessagingManager)
209180
SceneLoaderWrapper.Instance.AddOnSceneEventCallback();
Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Threading.Tasks;
32
using Unity.Multiplayer.Samples.BossRoom.ApplicationLifecycle.Messages;
43
using Unity.Multiplayer.Samples.BossRoom.Shared.Infrastructure;
54
using Unity.Netcode;
@@ -19,11 +18,6 @@ public ConnectedConnectionState(ConnectionManager connectionManager, IPublisher<
1918
m_ConnectStatusPublisher = connectStatusPublisher;
2019
}
2120

22-
public override void OnClientConnected(ulong clientId)
23-
{
24-
throw new NotImplementedException();
25-
}
26-
2721
public override void OnClientDisconnect(ulong clientId)
2822
{
2923
// This is also called on the Host when a different client disconnects. To make sure we only handle our own disconnection, verify that we are either
@@ -48,45 +42,5 @@ public override void OnClientDisconnect(ulong clientId)
4842
m_ConnectionManager.DisconnectReason.Clear();
4943
}
5044
}
51-
52-
public override void OnServerStarted()
53-
{
54-
throw new NotImplementedException();
55-
}
56-
57-
public override void StartClientIP(string playerId, string playerName, string ipaddress, int port)
58-
{
59-
throw new NotImplementedException();
60-
}
61-
62-
public override Task StartClientLobbyAsync(string playerName, string playerId, Action<string> onFailure)
63-
{
64-
throw new NotImplementedException();
65-
}
66-
67-
public override bool StartHostIP(string playerId, string playerName, string ipaddress, int port)
68-
{
69-
throw new NotImplementedException();
70-
}
71-
72-
public override Task StartHostLobbyAsync(string playerId, string playerName)
73-
{
74-
throw new NotImplementedException();
75-
}
76-
77-
public override void OnUserRequestedShutdown()
78-
{
79-
throw new NotImplementedException();
80-
}
81-
82-
public override void OnServerShutdown()
83-
{
84-
throw new NotImplementedException();
85-
}
86-
87-
public override void ApprovalCheck(byte[] connectionData, ulong clientId, NetworkManager.ConnectionApprovedDelegate connectionApprovedCallback)
88-
{
89-
throw new NotImplementedException();
90-
}
9145
}
9246
}
Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using System;
2-
using System.Threading.Tasks;
32
using Unity.Multiplayer.Samples.BossRoom.ApplicationLifecycle.Messages;
43
using Unity.Multiplayer.Samples.BossRoom.Shared.Infrastructure;
5-
using Unity.Netcode;
64

75
namespace Unity.Multiplayer.Samples.BossRoom
86
{
@@ -32,45 +30,10 @@ public override void OnClientDisconnect(ulong clientId)
3230
m_ConnectionManager.ChangeState(ConnectionStateType.Offline);
3331
}
3432

35-
public override void OnServerStarted()
36-
{
37-
throw new NotImplementedException();
38-
}
39-
40-
public override void StartClientIP(string playerId, string playerName, string ipaddress, int port)
41-
{
42-
throw new NotImplementedException();
43-
}
44-
45-
public override Task StartClientLobbyAsync(string playerName, string playerId, Action<string> onFailure)
46-
{
47-
throw new NotImplementedException();
48-
}
49-
50-
public override bool StartHostIP(string playerId, string playerName, string ipaddress, int port)
51-
{
52-
throw new NotImplementedException();
53-
}
54-
55-
public override Task StartHostLobbyAsync(string playerId, string playerName)
56-
{
57-
throw new NotImplementedException();
58-
}
59-
6033
public override void OnUserRequestedShutdown()
6134
{
6235
m_ConnectionManager.NetworkManager.Shutdown();
6336
m_ConnectionManager.ChangeState(ConnectionStateType.Offline);
6437
}
65-
66-
public override void OnServerShutdown()
67-
{
68-
throw new NotImplementedException();
69-
}
70-
71-
public override void ApprovalCheck(byte[] connectionData, ulong clientId, NetworkManager.ConnectionApprovedDelegate connectionApprovedCallback)
72-
{
73-
throw new NotImplementedException();
74-
}
7538
}
7639
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
using Unity.Netcode;
4+
5+
namespace Unity.Multiplayer.Samples.BossRoom
6+
{
7+
public abstract class ConnectionState
8+
{
9+
protected ConnectionManager m_ConnectionManager;
10+
11+
public ConnectionState(ConnectionManager connectionManager)
12+
{
13+
m_ConnectionManager = connectionManager;
14+
}
15+
16+
public virtual void OnClientConnected(ulong clientId) {}
17+
public virtual void OnClientDisconnect(ulong clientId) {}
18+
19+
public virtual void OnServerStarted() {}
20+
21+
public virtual void StartClientIP(string playerId, string playerName, string ipaddress, int port) {}
22+
23+
public virtual Task StartClientLobbyAsync(string playerName, string playerId, Action<string> onFailure)
24+
{
25+
return Task.CompletedTask;
26+
}
27+
28+
public virtual bool StartHostIP(string playerId, string playerName, string ipaddress, int port)
29+
{
30+
return false;
31+
}
32+
33+
public virtual Task StartHostLobbyAsync(string playerId, string playerName)
34+
{
35+
return Task.CompletedTask;
36+
}
37+
38+
public virtual void OnUserRequestedShutdown() {}
39+
40+
public virtual void OnServerShutdown() {}
41+
42+
public virtual void ApprovalCheck(byte[] connectionData, ulong clientId, NetworkManager.ConnectionApprovedDelegate connectionApprovedCallback) {}
43+
}
44+
}

Assets/BossRoom/Scripts/Gameplay/ConnectionManagement/ConnectionState/ConnectionState.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/BossRoom/Scripts/Gameplay/ConnectionManagement/ConnectionState/HostingConnectionState.cs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
using System;
22
using System.Collections;
3-
using System.Threading.Tasks;
43
using Unity.Multiplayer.Samples.BossRoom.Shared.Infrastructure;
54
using Unity.Multiplayer.Samples.BossRoom.Shared.Net.UnityServices.Lobbies;
6-
using Unity.Multiplayer.Samples.Utilities;
75
using Unity.Netcode;
86
using UnityEngine;
97

@@ -59,43 +57,13 @@ public override void OnClientDisconnect(ulong clientId)
5957
}
6058
}
6159

62-
public override void OnServerStarted()
63-
{
64-
65-
}
66-
67-
public override void StartClientIP(string playerId, string playerName, string ipaddress, int port)
68-
{
69-
throw new NotImplementedException();
70-
}
71-
72-
public override Task StartClientLobbyAsync(string playerName, string playerId, Action<string> onFailure)
73-
{
74-
throw new NotImplementedException();
75-
}
76-
77-
public override bool StartHostIP(string playerId, string playerName, string ipaddress, int port)
78-
{
79-
throw new NotImplementedException();
80-
}
81-
82-
public override Task StartHostLobbyAsync(string playerId, string playerName)
83-
{
84-
throw new NotImplementedException();
85-
}
86-
8760
public override void OnUserRequestedShutdown()
8861
{
8962
ConnectionManager.SendServerToAllClientsSetDisconnectReason(ConnectStatus.HostEndedSession);
9063
// Wait before shutting down to make sure clients receive that message before they are disconnected
9164
m_ConnectionManager.StartCoroutine(WaitToShutdown());
9265
}
9366

94-
public override void OnServerShutdown()
95-
{
96-
throw new NotImplementedException();
97-
}
98-
9967
public override void ApprovalCheck(byte[] connectionData, ulong clientId, NetworkManager.ConnectionApprovedDelegate connectionApprovedCallback)
10068
{
10169
if (connectionData.Length > k_MaxConnectPayload)

Assets/BossRoom/Scripts/Gameplay/ConnectionManagement/ConnectionState/OfflineConnectionState.cs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,6 @@ public OfflineConnectionState(ConnectionManager connectionManager, LobbyServiceF
2626
m_LocalLobby = localLobby;
2727
}
2828

29-
public override void OnClientConnected(ulong clientId)
30-
{
31-
}
32-
33-
public override void OnClientDisconnect(ulong clientId)
34-
{
35-
throw new NotImplementedException();
36-
}
37-
38-
public override void OnServerStarted()
39-
{
40-
throw new NotImplementedException();
41-
}
42-
4329
public override void StartClientIP(string playerId, string playerName, string ipaddress, int port)
4430
{
4531
var utp = (UnityTransport)m_ConnectionManager.NetworkManager.NetworkConfig.NetworkTransport;
@@ -115,16 +101,6 @@ public override async Task StartHostLobbyAsync(string playerId, string playerNam
115101
}
116102
}
117103

118-
public override void OnUserRequestedShutdown()
119-
{
120-
throw new NotImplementedException();
121-
}
122-
123-
public override void OnServerShutdown()
124-
{
125-
throw new NotImplementedException();
126-
}
127-
128104
public override void ApprovalCheck(byte[] connectionData, ulong clientId, NetworkManager.ConnectionApprovedDelegate connectionApprovedCallback)
129105
{
130106
if (m_ConnectionManager.NetworkManager.IsHost)

0 commit comments

Comments
 (0)