refactor: configure frame rate in a virtual method (#638)

Moved frame rate configuration into a virtual method so that people can override it and we reduce StartServer complexity

Fixes #567
This commit is contained in:
Paul Pacheco 2019-03-24 08:58:11 -05:00 committed by GitHub
parent 2d492607c8
commit a495f66fc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -240,13 +240,8 @@ internal void RegisterServerMessages()
NetworkServer.RegisterHandler<ErrorMessage>(OnServerErrorInternal);
}
public bool StartServer()
public virtual void ConfigureServerFrameRate()
{
InitializeSingleton();
if (runInBackground)
Application.runInBackground = true;
// set a fixed tick rate instead of updating as often as possible
// * if not in Editor (it doesn't work in the Editor)
// * if not in Host mode
@ -257,6 +252,16 @@ public bool StartServer()
Debug.Log("Server Tick Rate set to: " + Application.targetFrameRate + " Hz.");
}
#endif
}
public bool StartServer()
{
InitializeSingleton();
if (runInBackground)
Application.runInBackground = true;
ConfigureServerFrameRate();
if (!NetworkServer.Listen(maxConnections))
{