Initial Client Connection Code:
m_ClientNetworkIdQuery = m_clientWorld.EntityManager.CreateEntityQuery(ComponentType.ReadOnly<NetworkId>());
var clientConnectionRequestEntity = m_clientWorld.EntityManager.CreateEntity();
m_clientWorld.EntityManager.AddComponentData(clientConnectionRequestEntity, get_client_credentials());
using var networkDriverQuery = m_clientWorld.EntityManager.CreateEntityQuery(ComponentType.ReadWrite<NetworkStreamDriver>());
networkDriverQuery.GetSingletonRW<NetworkStreamDriver>().ValueRW.Connect(m_clientWorld.EntityManager, connectionEndPoint, clientConnectionRequestEntity);
Server Side connected event checking:
public void OnUpdate(ref SystemState state)
{
var ecb = new EntityCommandBuffer(Allocator.Temp);
foreach (var evt in SystemAPI.GetSingleton<NetworkStreamDriver>().ConnectionEventsForTick) {
Entity connectedEntity = evt.ConnectionEntity;
bool hasClientLoginCreds = SystemAPI.HasComponent<ClientLoginCredentials>(connectedEntity);
Debug.Log($"hasclientlogincreds:{hasClientLoginCreds} ConnectionState: {evt.State.ToFixedString()}");
}
ecb.Playback(state.EntityManager);
}
ClientLoginCredentials is an IComponentData that is also returned by get_client_credentials.
The server log when the event is Connected however indicates that ‘hasClientLoginCreds’ is false.
Note that I can (and do) pass the info directly after the fact via a client system that adds the same data as an RPC/SendRpcCommandRequest pair and a server system that receives it, but it doesn’t receive it until after the server side connection event has already fired, making the connection event not useful for client credential checking and identification.
I’d prefer to simplify things by passing all relevant client info directly into the connect function (or the entity sent to the connect function) and to be able to reliably retrieve it when the connected event fires as in the above code so I can decide then and there if the credentials pass or to drop the connection, rather than having to do it as a separate step afterward.
How can I do that?