Skip to content

Commit c2c1611

Browse files
committed
fix: Fixed internal delegate invocation
1 parent 4c77e43 commit c2c1611

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

MLAPI/Core/NetworkingManager.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,24 @@ internal set
152152
/// The callback to invoke once a client connects
153153
/// </summary>
154154
public event Action<ulong> OnClientConnectedCallback = null;
155+
internal void InvokeOnClientConnectedCallback(ulong clientId)
156+
{
157+
if (OnClientConnectedCallback != null)
158+
{
159+
OnClientConnectedCallback(clientId);
160+
}
161+
}
155162
/// <summary>
156163
/// The callback to invoke when a client disconnects
157164
/// </summary>
158165
public event Action<ulong> OnClientDisconnectCallback = null;
166+
internal void InvokeOnClientDisconnectCallback(ulong clientId)
167+
{
168+
if (OnClientDisconnectCallback != null)
169+
{
170+
OnClientDisconnectCallback(clientId);
171+
}
172+
}
159173
/// <summary>
160174
/// The callback to invoke once the server is ready
161175
/// </summary>
@@ -173,6 +187,13 @@ internal set
173187
/// The callback to invoke during connection approval
174188
/// </summary>
175189
public event Action<byte[], ulong, ConnectionApprovedDelegate> ConnectionApprovalCallback = null;
190+
internal void InvokeConnectionApproval(byte[] payload, ulong clientId, ConnectionApprovedDelegate action)
191+
{
192+
if (ConnectionApprovalCallback != null)
193+
{
194+
ConnectionApprovalCallback(payload, clientId, action);
195+
}
196+
}
176197
/// <summary>
177198
/// The current NetworkingConfiguration
178199
/// </summary>

MLAPI/Messaging/InternalMessageHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ internal static void HandleConnectionRequest(ulong clientId, Stream stream)
186186
if (NetworkingManager.Singleton.NetworkConfig.ConnectionApproval)
187187
{
188188
byte[] connectionBuffer = reader.ReadByteArray();
189-
NetworkingManager.Singleton.ConnectionApprovalCallback(connectionBuffer, clientId, (createPlayerObject, playerPrefabHash, approved, position, rotation) =>
189+
NetworkingManager.Singleton.InvokeConnectionApproval(connectionBuffer, clientId, (createPlayerObject, playerPrefabHash, approved, position, rotation) =>
190190
{
191191
NetworkingManager.Singleton.HandleApproval(clientId, createPlayerObject, playerPrefabHash, approved, position, rotation);
192192
});
@@ -288,7 +288,7 @@ void DelayedSpawnAction(Stream continuationStream)
288288

289289
NetworkingManager.Singleton.IsConnectedClient = true;
290290

291-
if (NetworkingManager.Singleton.OnClientConnectedCallback != null) NetworkingManager.Singleton.OnClientConnectedCallback.Invoke(NetworkingManager.Singleton.LocalClientId);
291+
NetworkingManager.Singleton.InvokeOnClientConnectedCallback(NetworkingManager.Singleton.LocalClientId);
292292
}
293293
}
294294

0 commit comments

Comments
 (0)