I think you can edit the simple example from the documentation to inform the users that they have to make sure the event queue is empty before calling the ScheduleUpdate().Complete() again. Otherwise there will be an error:
To break the example you can edit the ClientBehaviour.cs as follows:
void Update()
{
m_Driver.ScheduleUpdate().Complete();
if (!m_Connection.IsCreated)
{
return;
}
//added code
if (m_Connection.IsCreated && m_Connection.GetState(m_Driver) == NetworkConnection.State.Connected)
{
m_Driver.Disconnect(m_Connection);
m_Connection = default;
}
//
(...)
To fix the example again, you empty the queue at the very end of Update() in ClientBehaviour.cs:
while (m_Driver.PopEvent(out _, out _) != NetworkEvent.Type.Empty);
It is all because the client decided to disconnect while there were some events sent from the server in the queue. Then in the event loop the connection was set to default and the events were not popped.
It sounds like an artificial example, but I experienced this problem when working on my code. I think the situation may be even worse if someone is sending state updates every frame.