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

3 days ago
using Unity.Burst;
using Unity.Collections;
using Unity.Jobs;
using Unity.Networking.Transport;
using UnityEngine;
3 days ago
namespace ECSTest
{
[BurstCompile]
public struct ServerReceiveJob : IJobParallelForDefer
{
public NetworkDriver.Concurrent driver;
3 days ago
[ReadOnly]
public NativeList<NetworkConnection> connectionList;
public NativeList<int>.ParallelWriter disconnectIndexList;
public void Execute(int index)
{
3 days ago
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");
}
}
}
}
3 days ago
}