Compacted Receive loop

This commit is contained in:
Albin Corén 2018-04-23 21:21:18 +02:00
parent 52c4b4e0ef
commit 2cee9b0942

View File

@ -939,105 +939,73 @@ namespace MLAPI.MonoBehaviours.Core
{ {
case 0: //Client to server > sends connection buffer case 0: //Client to server > sends connection buffer
if (isServer) if (isServer)
{
InternalMessageHandler.HandleConnectionRequest(clientId, incommingData, channelId); InternalMessageHandler.HandleConnectionRequest(clientId, incommingData, channelId);
}
break; break;
case 1: //Server informs client it has been approved: case 1: //Server informs client it has been approved:
if (isClient) if (isClient)
{
InternalMessageHandler.HandleConnectionApproved(clientId, incommingData, channelId); InternalMessageHandler.HandleConnectionApproved(clientId, incommingData, channelId);
}
break; break;
case 2: case 2:
//Server informs client another client connected //Server informs client another client connected
//MLAPI_ADD_OBJECT //MLAPI_ADD_OBJECT
if (isClient) if (isClient)
{
InternalMessageHandler.HandleAddObject(clientId, incommingData, channelId); InternalMessageHandler.HandleAddObject(clientId, incommingData, channelId);
}
break; break;
case 3: case 3:
//Server informs client another client disconnected //Server informs client another client disconnected
//MLAPI_CLIENT_DISCONNECT //MLAPI_CLIENT_DISCONNECT
if (isClient) if (isClient)
{
InternalMessageHandler.HandleClientDisconnect(clientId, incommingData, channelId); InternalMessageHandler.HandleClientDisconnect(clientId, incommingData, channelId);
}
break; break;
case 4: case 4:
//Server infroms clients to destroy an object //Server infroms clients to destroy an object
if (isClient) if (isClient)
{
InternalMessageHandler.HandleDestroyObject(clientId, incommingData, channelId); InternalMessageHandler.HandleDestroyObject(clientId, incommingData, channelId);
}
break; break;
case 5: case 5:
//Scene switch //Scene switch
if (isClient) if (isClient)
{
InternalMessageHandler.HandleSwitchScene(clientId, incommingData, channelId); InternalMessageHandler.HandleSwitchScene(clientId, incommingData, channelId);
}
break; break;
case 6: //Spawn pool object case 6: //Spawn pool object
if (isClient) if (isClient)
{
InternalMessageHandler.HandleSpawnPoolObject(clientId, incommingData, channelId); InternalMessageHandler.HandleSpawnPoolObject(clientId, incommingData, channelId);
}
break; break;
case 7: //Destroy pool object case 7: //Destroy pool object
if (isClient) if (isClient)
{
InternalMessageHandler.HandleDestroyPoolObject(clientId, incommingData, channelId); InternalMessageHandler.HandleDestroyPoolObject(clientId, incommingData, channelId);
}
break; break;
case 8: //Change owner case 8: //Change owner
if (isClient) if (isClient)
{
InternalMessageHandler.HandleChangeOwner(clientId, incommingData, channelId); InternalMessageHandler.HandleChangeOwner(clientId, incommingData, channelId);
}
break; break;
case 9: //Syncvar case 9: //Syncvar
if (isClient) if (isClient)
{
InternalMessageHandler.HandleSyncVarUpdate(clientId, incommingData, channelId); InternalMessageHandler.HandleSyncVarUpdate(clientId, incommingData, channelId);
}
break; break;
case 10: case 10:
if (isClient) //MLAPI_ADD_OBJECTS (plural) if (isClient) //MLAPI_ADD_OBJECTS (plural)
{
InternalMessageHandler.HandleAddObjects(clientId, incommingData, channelId); InternalMessageHandler.HandleAddObjects(clientId, incommingData, channelId);
}
break; break;
case 11: case 11:
if (isClient) if (isClient)
{
InternalMessageHandler.HandleTimeSync(clientId, incommingData, channelId); InternalMessageHandler.HandleTimeSync(clientId, incommingData, channelId);
}
break; break;
case 12: case 12:
if (isServer) if (isServer)
{
InternalMessageHandler.HandleCommand(clientId, incommingData, channelId); InternalMessageHandler.HandleCommand(clientId, incommingData, channelId);
}
break; break;
case 13: case 13:
if (isClient) if (isClient)
{
InternalMessageHandler.HandleRpc(clientId, incommingData, channelId); InternalMessageHandler.HandleRpc(clientId, incommingData, channelId);
}
break; break;
case 14: case 14:
if (isClient) if (isClient)
{
InternalMessageHandler.HandleTargetRpc(clientId, incommingData, channelId); InternalMessageHandler.HandleTargetRpc(clientId, incommingData, channelId);
}
break; break;
case 15: case 15:
if (isClient) if (isClient)
{
InternalMessageHandler.HandleSetVisibility(clientId, incommingData, channelId); InternalMessageHandler.HandleSetVisibility(clientId, incommingData, channelId);
}
break; break;
} }
#endregion #endregion