public NetManager(RecyclableMemoryManager memoryManager)
        {
            MemoryManager = memoryManager ?? throw new ArgumentNullException(nameof(memoryManager));

            Codec        = new NetPacketCodec(MemoryManager);
            Orchestrator = new NetOrchestrator(MemoryManager, Codec);
            Listener     = new NetListener(Orchestrator, AcceptConnection);

            _connections = new HashSet <NetConnection>();
            Connections  = _connections.AsReadOnly();
        }
        private bool AcceptConnection(NetListener sender, NetConnection connection)
        {
            lock (ConnectionMutex)
            {
                if (!_connections.Add(connection))
                {
                    throw new InvalidOperationException(); // This should never occur.
                }
            }

            // TODO: manage connection tasks
            // TODO: validate client
            var connectionTask = Codec.EngageClientConnection(connection, cancellationToken: default);

            return(true);
        }