protected override JobHandle OnUpdate(JobHandle inputDep)
    {
        if (!m_DriverSystem.ClientDriver.IsCreated)
        {
            return(inputDep);
        }
        PingClientUIBehaviour.UpdateStats(m_pingStats[0], m_pingStats[1]);
        if (PingClientUIBehaviour.ServerEndPoint.IsValid && m_ConnectionGroup.IsEmptyIgnoreFilter)
        {
            var conJob = new ConnectJob
            {
                driver        = m_DriverSystem.ClientDriver,
                serverEP      = PingClientUIBehaviour.ServerEndPoint,
                commandBuffer = m_Barrier.CreateCommandBuffer()
            };
            inputDep = conJob.Schedule(inputDep);
            m_Barrier.AddJobHandleForProducer(inputDep);
            return(inputDep);
        }
        var pingJob = new PingJob
        {
            driver        = m_DriverSystem.ClientDriver,
            serverEP      = PingClientUIBehaviour.ServerEndPoint,
            pendingPings  = m_pendingPings,
            pingStats     = m_pingStats,
            fixedTime     = Time.fixedTime,
            commandBuffer = m_Barrier.CreateCommandBuffer()
        };
        var handle = pingJob.ScheduleSingle(this, inputDep);

        m_Barrier.AddJobHandleForProducer(handle);
        return(handle);
    }
Beispiel #2
0
        // Non-blocking; ticks ping state machine once
        //   3+ ticks required to do a full cycle (connect, send, receive + disconnect)
        void RunPingJob()
        {
            // Write stats from last job
            Stats.AddEntry(m_NumPings[0], m_LastPing[0]);

            // Disconnect if we exceeded our disconnect timeout
            if (m_ClientToServerConnection.Length > 0 &&
                m_ClientToServerConnection[0].IsCreated &&
                m_NumPings[0] == m_PendingPings[0].id &&
                Time.fixedTime - m_PendingPings[0].time > k_PingTimeoutMs)
            {
                Debug.Log($"Resetting connection to ping server due to ping timeout (time waiting for response > {k_PingTimeoutMs} ms).");
                m_ClientToServerConnection[0].Disconnect(m_ClientDriver);
                m_ClientToServerConnection[0] = default;
            }

            // Schedule driver update
            updateHandle = m_ClientDriver.ScheduleUpdate();

            var pingJob = new PingJob
            {
                driver       = m_ClientDriver,
                connection   = m_ClientToServerConnection,
                serverEp     = m_ServerEndpoint,
                pendingPings = m_PendingPings,
                numPings     = m_NumPings,
                lastPing     = m_LastPing
            };

            // Schedule an update chain with the driver update followed by the ping job
            updateHandle = pingJob.Schedule(updateHandle);

            JobHandle.ScheduleBatchedJobs();
        }
Beispiel #3
0
        /// <summary>
        /// Starts a new job
        /// </summary>
        public PingJob StartNew()
        {
            var job = new PingJob(this);

            Jobs.Add(job);
            CurrentJob = job;
            job.Start();
            return(job);
        }
 /// <inheritdoc/>
 protected override void ProcessRecord()
 {
     foreach (var cn in ComputerName)
     {
         var job = new PingJob(MyInvocation.Line, Name, cn);
         JobRepository.Add(job);
         job.StartJob();
         WriteObject(job);
     }
 }
Beispiel #5
0
    protected override JobHandle OnUpdate(JobHandle inputDep)
    {
        if (!m_DriverSystem.ClientDriver.IsCreated)
        {
            return(inputDep);
        }
        PingClientUIBehaviour.UpdateStats(m_pingStats[0], m_pingStats[1]);
        var pingJob = new PingJob
        {
            driver             = m_DriverSystem.ClientDriver,
            connections        = connectionList.connections,
            connectionEntities = connectionList.entities,
            serverEP           = PingClientUIBehaviour.ServerEndPoint,
            pendingPings       = m_pendingPings,
            pingStats          = m_pingStats,
            fixedTime          = Time.fixedTime,
            commandBuffer      = m_Barrier.CreateCommandBuffer()
        };

        return(pingJob.Schedule(inputDep));
    }
Beispiel #6
0
        public void PingJob_ShallNot_Exceed_Timeout()
        {
            Mock <ILogger> mockLogger = new Mock <ILogger>();
            Mock <ISettingContainer <UrlAddress> > mockUrls = new Mock <ISettingContainer <UrlAddress> >();

            mockUrls.Setup(m => m.Contains("PingUrl")).Returns(true);
            mockUrls.SetupGet(m => m["PingUrl"]).Returns(new UrlAddress()
            {
                Address = "http://www.google.com"
            });

            Mock <ISettingManager> settingManagerMock = new Mock <ISettingManager>();

            settingManagerMock.Setup(m => m.GetContainer <UrlAddress>()).Returns(mockUrls.Object);

            PingJob   job = new PingJob(mockLogger.Object, settingManagerMock.Object);
            Stopwatch sw  = Stopwatch.StartNew();

            job.Execute();
            sw.Stop();
            Assert.True(sw.ElapsedMilliseconds < 6000);
        }
    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();

        // Update the ping client UI with the ping statistics computed by teh job scheduled previous frame since that
        // is now guaranteed to have completed
        PingClientUIBehaviour.UpdateStats(m_pingStats[0], m_pingStats[1]);
        var pingJob = new PingJob
        {
            driver       = m_ClientDriver,
            connection   = m_clientToServerConnection,
            serverEP     = PingClientUIBehaviour.ServerEndPoint,
            pendingPings = m_pendingPings,
            pingStats    = m_pingStats,
            fixedTime    = Time.fixedTime
        };

        // Schedule a chain with the driver update followed by the ping job
        m_updateHandle = m_ClientDriver.ScheduleUpdate();
        m_updateHandle = pingJob.Schedule(m_updateHandle);
    }
Beispiel #8
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
        m_updateHandle.Complete();

        var serverEP = PingClientUIBehaviour.ServerEndPoint;

        // If the client ui indicates we should be sending pings but we do not have an active connection we create one
        if (serverEP.IsValid && !m_clientToServerConnection[0].IsCreated)
        {
            m_clientToServerConnection[0] = m_ClientDriver.Connect(serverEP);
        }
        // If the client ui indicates we should not be sending pings but we do have a connection we close that connection
        if (!serverEP.IsValid && m_clientToServerConnection[0].IsCreated)
        {
            m_clientToServerConnection[0].Disconnect(m_ClientDriver);
            m_clientToServerConnection[0] = default(NetworkConnection);
        }

        // Update the ping client UI with the ping statistics computed by teh job scheduled previous frame since that
        // is now guaranteed to have completed
        PingClientUIBehaviour.UpdateStats(m_pingStats[0], m_pingStats[1]);
        var pingJob = new PingJob
        {
            driver       = m_ClientDriver,
            connection   = m_clientToServerConnection,
            pendingPings = m_pendingPings,
            pingStats    = m_pingStats,
            fixedTime    = Time.fixedTime
        };

        // Schedule a chain with the driver update followed by the ping job
        m_updateHandle = m_ClientDriver.ScheduleUpdate();
        m_updateHandle = pingJob.Schedule(m_updateHandle);
    }
 /// <summary>
 /// Initializes a new instance of the <see cref="PingReplyEventArgs"/> class.
 /// </summary>
 /// <param name="pingJob">The ping job.</param>
 /// <param name="pingReply">The ping reply.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <exception cref="ArgumentNullException">pingReply</exception>
 /// <autogeneratedoc />
 public PingReplyEventArgs(PingJob pingJob, PingReply pingReply, CancellationToken cancellationToken)
 {
     PingJob           = pingJob;
     PingReply         = pingReply ?? throw new ArgumentNullException(nameof(pingReply));
     CancellationToken = cancellationToken;
 }