using Unity.Burst; using Unity.Collections; using Unity.Jobs; using Unity.Networking.Transport; using UnityEngine; namespace ECSTest { [BurstCompile] public struct ServerReceiveJob : IJobParallelForDefer { public NetworkDriver.Concurrent driver; [ReadOnly] public NativeList connectionList; public NativeList.ParallelWriter disconnectIndexList; public void Execute(int index) { var connection = connectionList[index]; NetworkEvent.Type cmd; while ((cmd = driver.PopEventForConnection(connection, out var stream)) != NetworkEvent.Type.Empty) { if (cmd == NetworkEvent.Type.Data) { //TODO } else if (cmd == NetworkEvent.Type.Disconnect) { disconnectIndexList.AddNoResize(index); Debug.Log("[Server] Received a disconnection"); } } } } }