@@ -43,8 +43,8 @@ public bool isHost
43
43
internal int serverClientId ;
44
44
45
45
public bool IsClientConnected ;
46
- public Action OnClientConnectedCallback = null ;
47
- public Action OnClientDisconnectCallback = null ;
46
+ public Action < int > OnClientConnectedCallback = null ;
47
+ public Action < int > OnClientDisconnectCallback = null ;
48
48
public Action OnServerStarted = null ;
49
49
50
50
public NetworkingConfiguration NetworkConfig ;
@@ -352,11 +352,10 @@ private void Update()
352
352
return ;
353
353
}
354
354
else
355
- {
356
- if ( OnClientDisconnectCallback != null )
357
- OnClientDisconnectCallback . Invoke ( ) ;
358
355
IsClientConnected = false ;
359
- }
356
+
357
+ if ( OnClientDisconnectCallback != null )
358
+ OnClientDisconnectCallback . Invoke ( clientId ) ;
360
359
}
361
360
else if ( networkError != NetworkError . Ok )
362
361
{
@@ -400,12 +399,10 @@ private void Update()
400
399
if ( isServer )
401
400
OnClientDisconnect ( clientId ) ;
402
401
else
403
- {
404
- if ( OnClientDisconnectCallback != null )
405
- OnClientDisconnectCallback . Invoke ( ) ;
406
-
407
402
IsClientConnected = false ;
408
- }
403
+
404
+ if ( OnClientDisconnectCallback != null )
405
+ OnClientDisconnectCallback . Invoke ( clientId ) ;
409
406
break ;
410
407
}
411
408
// Only do another iteration if: there are no more messages AND (there is no limit to max events or we have processed less than the maximum)
@@ -565,7 +562,6 @@ private void HandleIncomingData(int clientId, byte[] data, int channelId)
565
562
case 1 : //Server informs client it has been approved:
566
563
if ( isClient )
567
564
{
568
- //SceneManager.LoadScene(PlaySceneIndex);
569
565
using ( MemoryStream messageReadStream = new MemoryStream ( incommingData ) )
570
566
{
571
567
using ( BinaryReader messageReader = new BinaryReader ( messageReadStream ) )
@@ -618,9 +614,9 @@ private void HandleIncomingData(int clientId, byte[] data, int channelId)
618
614
}
619
615
}
620
616
}
621
- if ( OnClientConnectedCallback != null )
622
- OnClientConnectedCallback . Invoke ( ) ;
623
617
IsClientConnected = true ;
618
+ if ( OnClientConnectedCallback != null )
619
+ OnClientConnectedCallback . Invoke ( clientId ) ;
624
620
}
625
621
break ;
626
622
case 2 :
@@ -1219,6 +1215,9 @@ private void HandleApproval(int clientId, bool approved)
1219
1215
}
1220
1216
}
1221
1217
Send ( clientId , "MLAPI_CONNECTION_APPROVED" , "MLAPI_INTERNAL" , writeStream . GetBuffer ( ) , null , true ) ;
1218
+
1219
+ if ( OnClientConnectedCallback != null )
1220
+ OnClientConnectedCallback . Invoke ( clientId ) ;
1222
1221
}
1223
1222
1224
1223
//Inform old clients of the new player
0 commit comments