void WaitForNetworkUpdate() { // The DriverUpdateJob which accepts new connections should be the second job in the chain, // it needs to depend on the driver update job var updateJob = new DriverUpdateJob { driver = m_ServerDriver, connections = m_Connections }; // Update the driver should be the first job in the chain m_UpdateHandle = m_ServerDriver.ScheduleUpdate(m_UpdateHandle); m_UpdateHandle = updateJob.Schedule(m_UpdateHandle); // Wait for the job to complete m_UpdateHandle.Complete(); }
void FixedUpdate() { // Wait for the previous frames ping to complete before starting a new one, the Complete in LateUpdate is not // enough since we can get multiple FixedUpdate per frame on slow clients m_updateHandle.Complete(); // If there is at least one client connected update the activity so the server is not shutdown if (m_connections.Length > 0) { DedicatedServerConfig.UpdateLastActivity(); } var updateJob = new DriverUpdateJob { driver = m_ServerDriver, connections = m_connections }; var pongJob = new PongJob { // PongJob is a ParallelFor job, it must use the concurrent NetworkDriver driver = m_ServerDriver.ToConcurrent(), // PongJob uses IJobParallelForDeferExtensions, we *must* use ToDeferredJobArray in order to access the // list from the job #if ENABLE_IL2CPP // IJobParallelForDeferExtensions is not working correctly with IL2CPP connections = m_connections #else connections = m_connections.ToDeferredJobArray() #endif }; // Update the driver should be the first job in the chain m_updateHandle = m_ServerDriver.ScheduleUpdate(); // The DriverUpdateJob which accepts new connections should be the second job in the chain, it needs to depend // on the driver update job m_updateHandle = updateJob.Schedule(m_updateHandle); // PongJob uses IJobParallelForDeferExtensions, we *must* schedule with a list as first parameter rather than // an int since the job needs to pick up new connections from DriverUpdateJob // The PongJob is the last job in the chain and it must depends on the DriverUpdateJob #if ENABLE_IL2CPP m_updateHandle = pongJob.Schedule(m_updateHandle); #else m_updateHandle = pongJob.Schedule(m_connections, 1, m_updateHandle); #endif } }