Exemple #1
0
    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

        // Schedule a chain with the driver update followed by the other jobs
        jobHandler.ScheduleDriverUpdate(m_ClientDriver);

        ConnectionUpdateJob conUpdate = new ConnectionUpdateJob
        {
            driver     = m_ClientDriver,
            connection = m_clientToServerConnection,
            serverEP   = endpoint
        };

        jobHandler.QueueJob(conUpdate);

        jobHandler.ScheduleJobsInQueue();

        jobHandler.Complete();

        if (IsConnected)
        {
            pcc.StartProcessCoroutine(m_clientToServerConnection[0]);
            m_clientToServerConnection[0] = pcc.connection;
        }
    }
Exemple #2
0
    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

        DriverUpdateJob updateJob = new DriverUpdateJob {
            driver      = m_ServerDriver,
            connections = m_connections,
            serverState = serverController.CurrentState
        };

        // Update the driver should be the first job in the chain
        jobHandler.ScheduleDriverUpdate(m_ServerDriver);
        // The DriverUpdateJob which accepts new connections should be the second job in the chain, it needs to depend
        // on the driver update job
        jobHandler.QueueJob(updateJob);
        // 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

        jobHandler.ScheduleJobsInQueue();

        jobHandler.Complete();

        for (int i = 0; i < m_connections.Length; i++)
        {
            pcc.StartProcessCoroutine(m_connections[i]);
            m_connections[i] = pcc.connection;
        }
    }