You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.0 KiB
37 lines
1.0 KiB
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<NetworkConnection> connectionList; |
|
public NativeList<int>.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"); |
|
} |
|
} |
|
} |
|
} |
|
} |