@@ -43,8 +43,8 @@ public bool isHost
4343 internal int serverClientId ;
4444
4545 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 ;
4848 public Action OnServerStarted = null ;
4949
5050 public NetworkingConfiguration NetworkConfig ;
@@ -352,11 +352,10 @@ private void Update()
352352 return ;
353353 }
354354 else
355- {
356- if ( OnClientDisconnectCallback != null )
357- OnClientDisconnectCallback . Invoke ( ) ;
358355 IsClientConnected = false ;
359- }
356+
357+ if ( OnClientDisconnectCallback != null )
358+ OnClientDisconnectCallback . Invoke ( clientId ) ;
360359 }
361360 else if ( networkError != NetworkError . Ok )
362361 {
@@ -400,12 +399,10 @@ private void Update()
400399 if ( isServer )
401400 OnClientDisconnect ( clientId ) ;
402401 else
403- {
404- if ( OnClientDisconnectCallback != null )
405- OnClientDisconnectCallback . Invoke ( ) ;
406-
407402 IsClientConnected = false ;
408- }
403+
404+ if ( OnClientDisconnectCallback != null )
405+ OnClientDisconnectCallback . Invoke ( clientId ) ;
409406 break ;
410407 }
411408 // 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)
565562 case 1 : //Server informs client it has been approved:
566563 if ( isClient )
567564 {
568- //SceneManager.LoadScene(PlaySceneIndex);
569565 using ( MemoryStream messageReadStream = new MemoryStream ( incommingData ) )
570566 {
571567 using ( BinaryReader messageReader = new BinaryReader ( messageReadStream ) )
@@ -618,9 +614,9 @@ private void HandleIncomingData(int clientId, byte[] data, int channelId)
618614 }
619615 }
620616 }
621- if ( OnClientConnectedCallback != null )
622- OnClientConnectedCallback . Invoke ( ) ;
623617 IsClientConnected = true ;
618+ if ( OnClientConnectedCallback != null )
619+ OnClientConnectedCallback . Invoke ( clientId ) ;
624620 }
625621 break ;
626622 case 2 :
@@ -1219,6 +1215,9 @@ private void HandleApproval(int clientId, bool approved)
12191215 }
12201216 }
12211217 Send ( clientId , "MLAPI_CONNECTION_APPROVED" , "MLAPI_INTERNAL" , writeStream . GetBuffer ( ) , null , true ) ;
1218+
1219+ if ( OnClientConnectedCallback != null )
1220+ OnClientConnectedCallback . Invoke ( clientId ) ;
12221221 }
12231222
12241223 //Inform old clients of the new player
0 commit comments