Hey there,
I'm trying to create my own INetworkInterfaces for Netcode for Entities. To get Netcode to use them, I do
NetworkStreamReceiveSystem.DriverConstructor = new NetworkStreamDriverConstructor();
before the usual stuff:
var server = ClientServerBootstrap.CreateServerWorld("ServerWorld");
var client = ClientServerBootstrap.CreateClientWorld("ClientWorld");
DestroyLocalSimulationWorld();
World.DefaultGameObjectInjectionWorld ??= server;
SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);
var serverQuery = server.EntityManager.CreateEntityQuery(ComponentType.ReadWrite<NetworkStreamDriver>());
serverQuery.GetSingletonRW<NetworkStreamDriver>().ValueRW.Listen(serverEP);
var clientQuery = client.EntityManager.CreateEntityQuery(ComponentType.ReadWrite<NetworkStreamDriver>());
clientQuery.GetSingletonRW<NetworkStreamDriver>().ValueRW.Connect(client.EntityManager, clientEP);
Behind the scenes, I'm already connected to one local client and one remote client by that point, and my custom INetworkInterfaces are going to use those connections.
I can see that for server and client the respective INetworkInterfaces are having their Bind() called and shortly after their ScheduleSend() and ScheduleReceive().
Both the local client as well as the remote client send 13 byte messages ending in UTP (or in byte values [85][84][80][1]) to the server. That happens in the clients' ScheduleSend() and gets all the way propagated to the server's ScheduleReceive() where I handle the messages like this:
if (!receiveQueue.EnqueuePacket(out var packetProcessor))
break;
packetProcessor.EndpointRef = IndexToEndpoint[msg.SenderIndex];
unsafe
{
fixed (byte* ptr = msg.PacketData)
{
packetProcessor.AppendToPayload(ptr, msg.PacketData.Length);
}
}
But then nothing happens. The server's SendQueue in ScheduleSend() is always empty. Is there something else I need to do to kickstart the process? I've been trying for days now and I'm all out of ideas. 😣
