问题
I plan to create an online RTS game that will use Quartz .NET for updating values in a postgresql database.
Here is an example of a scenario in the game.
A player will create a building and there is amount of time before it will be completed. The completion time will be computed and saved on a database.
Once the production of the building is commenced, I will create a quartz trigger that is set to act when the completion time of the building arrives. The trigger will initiate a job that will update a value on the database prompting that the building is already completed.
In this scenario, we can conclude that there can be hundred-of-thousand of quartz triggers, that can be created given a huge number of players on the game.
Here are my questions.
Is Quartz appropriate for this online application? If yes, should I have a separate server for hosting Quartz and its jobs and triggers? What should be the minimum spec of my server?
If Quartz is not appropriate for this, what can be some alternative solutions? I have seen a lot of online RTS game on the web that deals with unique completion of productions times of units, building but I don't have ideas for implementing them.
Thanks.
Yours,
Mark
回答1:
As said, you can update your database with the expected completion time. Also, there's probably no need to sync with your client on completion. You can tell the client: this building will be finished XYZ unless I tell you differently.
Most game servers probably don't use quartz, but an event loop of some sorts. Also; don't use your database for real-time updates. Do your updates in-memory and write through in background for better performance. In case of a crash you only loose the events that happened since your last write-through action.
来源:https://stackoverflow.com/questions/8238228/quartz-net-for-online-game-scheduling