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.
43 lines
1.2 KiB
43 lines
1.2 KiB
using Unity.Burst; |
|
using Unity.Collections; |
|
using Unity.Jobs; |
|
using Unity.Networking.Transport; |
|
using UnityEngine; |
|
|
|
namespace ECSTest |
|
{ |
|
[BurstCompile] |
|
public struct ClientUpdateJob : IJob |
|
{ |
|
public NetworkDriver driver; |
|
public NetworkPipeline unreliablePipeline; |
|
public NetworkPipeline reliablePipeline; |
|
public NativeReference<NetworkConnection> connection; |
|
|
|
public void Execute() |
|
{ |
|
if (connection.Value == default) |
|
return; |
|
|
|
NetworkEvent.Type cmd; |
|
while ((cmd = connection.Value.PopEvent(driver, out var stream, out var networkPipeline)) != |
|
NetworkEvent.Type.Empty) |
|
{ |
|
if (cmd == NetworkEvent.Type.Data) |
|
{ |
|
//TODO |
|
} |
|
else if (cmd == NetworkEvent.Type.Connect) |
|
{ |
|
Debug.Log("[Client] Connected to server"); |
|
//TODO |
|
} |
|
else if (cmd == NetworkEvent.Type.Disconnect) |
|
{ |
|
connection.Value = default; |
|
Debug.Log("[Client] Disconnected to server"); |
|
} |
|
} |
|
} |
|
} |
|
} |