public bool Listen(NetworkEndPoint endpoint) { LastDriverWriter.Complete(); // Switching to server mode if (m_Driver.Bind(endpoint) != 0) { return(false); } if (m_Driver.Listen() != 0) { return(false); } m_DriverListening = true; m_ConcurrentDriver = m_Driver.ToConcurrent(); return(true); }
public void Update() { m_Tick++; m_UpdateHandle.Complete(); if (m_PendingDisconnects.IsCreated) { m_PendingDisconnects.Dispose(); } var acceptJob = new SoakServerAcceptJob { now = m_Tick, driver = m_ServerDriver, connections = m_Connections }; var soakJob = new SoakServerUpdateClientsJob { driver = m_ServerDriver.ToConcurrent(), pipeline = m_Pipeline, connections = m_Connections.AsDeferredJobArray() }; /*var time = Time.fixedTime; * if (time > m_NextStatsPrint) * { * PrintStatistics(); * m_NextStatsPrint = time + 10; * }*/ m_UpdateHandle = m_ServerDriver.ScheduleUpdate(); m_UpdateHandle = acceptJob.Schedule(m_UpdateHandle); m_UpdateHandle = soakJob.Schedule(m_Connections, 1, m_UpdateHandle); }
public bool Listen(NetworkEndPoint endpoint) { LastDriverWriter.Complete(); // Switching to server mode if (m_Driver.Bind(endpoint) != 0) { return(false); } if (m_Driver.Listen() != 0) { return(false); } m_DriverListening = true; // FIXME: Bind breaks all copies of the driver nad makes them send to the wrong socket m_ConcurrentDriver = m_Driver.ToConcurrent(); return(true); }
private void Update() { mJob.Complete(); var updatec = new UpdateConnectionsJob(mDriver, mConnections); var updateh = new UpdateJob(mDriver.ToConcurrent(), mConnections.AsDeferredJobArray()); mJob = mDriver.ScheduleUpdate(); mJob = updatec.Schedule(mJob); mJob = updateh.Schedule(mConnections, 1, mJob); }
void Update() { ServerJobHandle.Complete(); var connectionJob = new ServerUpdateConnectionsJob { driver = m_Driver, connections = m_Connections }; var serverUpdateJob = new ServerUpdateJob { driver = m_Driver.ToConcurrent(), connections = m_Connections.AsDeferredJobArray() }; ServerJobHandle = m_Driver.ScheduleUpdate(); ServerJobHandle = connectionJob.Schedule(ServerJobHandle); ServerJobHandle = serverUpdateJob.Schedule(m_Connections, 1, ServerJobHandle); }
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 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 AsDeferredJobArray 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.AsDeferredJobArray() #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 } }