コード例 #1
0
        // Polite update - Wait for our jobs to complete naturally
        public void Update()
        {
            if (m_Disposed || m_ShuttingDown)
            {
                return;
            }

            m_SqpServer?.Update();

            // Don't do anything more unless our jobs have been completed
            if (!m_UpdateHandle.IsCompleted)
            {
                return;
            }

            // Wait for the previous frames ping to complete before starting a new one
            m_UpdateHandle.Complete();

            // Update the SQP server
            if (m_SqpServer != null)
            {
                m_Config.Info.CurrentPlayers = (ushort)m_Connections.Length;
            }

            // If there is at least one client connected update the activity so the server is not shutdown
            if (m_Connections.Length > 0)
            {
                DedicatedServerConfig.UpdateLastActivity();
            }

            // Update the network drivers and our list of active connections
            WaitForNetworkUpdate();

            // Figure out if we should wait for (and respond to) pings or shut down the server
            if (m_ShouldShutdownServer[0])
            {
                DisconnectClientsAndShutdown();
            }
            else
            {
                SchedulePongJob();

                // Put our jobs on the stack to be processed without waiting for completion in this frame
                JobHandle.ScheduleBatchedJobs();
            }
        }
コード例 #2
0
 void FixedUpdate()
 {
     // Update server
     m_Server?.Update();
 }