Scheduling events within a program

I need to know how to use the java.util.Timer class to schedule an assignment.



In making my MMORPG, the server has several classes that I have written to allow my MMORPG to actually BE an MMORPG. I'm using MySQL hosting and have written several classes that will manage reading from and writing to my tables in the game's database.



When the "Server" starts, it calls the Database and downloads Accounts, Characters, Armors, Weapons, Creatures, Creature_Templates, Loot_Tables, etc.



It then fits these into appropriate Data Structures (usually ArrayLists) and keeps them in the program to manage game functions. I want to schedule my program to (every 5 minutes) save a copy of the game into the database. My goal is that, during a server-crash (which I expect will happen moderately frequently, like every 8 hours or so?) everything will be in the state it was in at most 5 minutes before the crash. For example, if I started in a Capital City and ran like 8 hours to get to some other Capital City and the server crashed, with this method my location (x,y,z) would be stored in the database at some point within the last five minutes. This way, when the server restarts itself, I don't have to re-run the 8 hours, since the server wasn't shut down properly (which is where the normal saving would take place).



In addition, I don't really want my servers to EVER shut down, unless I'm doing maintenance, and this would help that.



If you have any suggestions on OTHER ways to accomplish my goals, please tell me.



Otherwise, how do I schedule tasks with java.util.Timer?

The Project DarkStar could take care of this persistence stuff for you.

But it add another layer of complexity.



Did you decide already what kind of network api you are gonna use yet ?

Core-Dump said:

Did you decide already what kind of network api you are gonna use yet ?


Sockets with a Thin Server / Fat Client type of game.
Core-Dump said:

The Project DarkStar could take care of this persistence stuff for you.
But it add another layer of complexity.

Did you decide already what kind of network api you are gonna use yet ?


As Darkstar's dad I have to say the opposite... it will REMOVE a great deal of the complexity currently in your code, while giving
you a unified task model for your events and eventually scalability and fail-over (when we've really finished multi-node.)

BUT if you've already gone down a path you may not want to switch gears.

Just a warning... building a server that will handle a dozen players is easy.
Scaling that to thousands in a reliable way is much much harder.

I know I'll live to regret saying this, but I have to agree with Jeff.  If you decide to use Darkstar, this is one of its primary advantages.



However, the decision to use Darkstar, custom code, or something else entirely (JGN perhaps…) is a different question.  I would highly recommend against writing your own networking code as there are MANY pitfalls you'll find, especially in a MMORPG game. Rather than wasting time re-creating a networking system for your game I think it makes more sense to use someone else's tried-and-true system and focus on writing your game.



Whatever you end up using, it is in your best interests to investigate the alternatives before biting off the networking beast.

The frog and I totally agree here…



an MMORPG is a HUGE amount of work.  If you evre hope to complete it makes sense to leverage as much other stuff thats been done for you and focus your effort just on where the existing tools wont do what you need.



After all, you could use LWJGL directly and write your own scenegrpah… but theres a reason we're all here at the JME site :wink:

Is Project Darkstar easy to use? Because with sockets I'd just have to write a few methods in a Network_Manager class and have it execute several methods every second. My main concern was that the server couldn't work that fast…

I would recommend taking a look at both JGN and Darkstar. Both have their strengths and weaknesses. If you want simplicity I think you'll find JGN a lot faster to get going, but Darkstar has a lot of really cool features when it comes to MMO development.

darkfrog said:

I would recommend taking a look at both JGN and Darkstar. Both have their strengths and weaknesses. If you want simplicity I think you'll find JGN a lot faster to get going, but Darkstar has a lot of really cool features when it comes to MMO development.


If it can figure out for itself (based on method parameters) how close two players are, I'd love to use it.

Tell me if I'm where I need to be with understanding how this will work.

Every cycle, the server will send to each online client an ArrayList of characters that are within 150 yards of them, so the clients can render them. Then, if a client says something, it will tell the server what it says and the server will broadcast to every player on that "nearbyPlayers" arrayList, so they can all see the chat, etc?

JGN can help you do that far easier, and thread safely.  JGN isn’t really meant to be a complex framework that does everything for you. Rather, it is intended to be simple, straight-forward API to make networking smooth and logical for game development (however, some companies have been using it recently as well for non-game network communication). The idea of JGN is centered around the Message. It is easy to create your own custom Messages simply by extending the Message class and adding additional fields.  Messages are processed remotely via MessageListeners. There is a lot of functionality provided in JGN, but the core is extremely simple.



I would encourage you to take a look at the project and although the documentation is growing (community contributions) you can find everything you need in the tests package in the source.



http://javagn.org

I am tempted for requesting the listing of 10 commercial JME releases… or else :stuck_out_tongue:

Mindgamer, a risk analysis.



jme have one commercial release and a few in commercial production, but have been used by many for a long time. yes jme is a risk but of a faily low risk now.



in other hand, darkfrog networking started and not finished, still immature, lot of risk in using. Darkstar have resource to test many clients working, so less risk for darkstar.






There are at least 10 games using JGN out there, but I just do a crappy job of keeping up with them. :o



How do you figure that JGN is started and not finished?  Definitely it's growing, but I believe has maintained a stable 2.0 longer than the latest re-write of Darkstar.  I do this in my spare time so I don't have the time to market it much or do much other than just maintenance, but you can just look around on our forum and you'll see the speed in response in bug-fixes as well happiness from users of it.



Can any of you name ten commercial game releases for jME?  How about even five for Darkstar?  How do you think a framework reaches that "industry standard ten"?  If nobody ever uses a framework because nobody is using it no project would ever get anywhere.  We'd all be writing Cobol, or Fortran, or some other crappy language.

darkfrog said:

http://javagn.org


Thank yoU!
Trussell said:

darkfrog said:

I would recommend taking a look at both JGN and Darkstar. Both have their strengths and weaknesses. If you want simplicity I think you'll find JGN a lot faster to get going, but Darkstar has a lot of really cool features when it comes to MMO development.


If it can figure out for itself (based on method parameters) how close two players are, I'd love to use it.

Tell me if I'm where I need to be with understanding how this will work.

Every cycle, the server will send to each online client an ArrayList of characters that are within 150 yards of them, so the clients can render them. Then, if a client says something, it will tell the server what it says and the server will broadcast to every player on that "nearbyPlayers" arrayList, so they can all see the chat, etc?


So typically approach this a bit differently in a Darkstar based app.

Darkstar isn't a "game engine". It has no concept itself of where or what objects are.  In fact its not specific to physical simulations at all.  It provides the underpinnigns that take care of communication (on a low level, byte packet based) and making sever side logic failure proof, massively scalable and persistant.

When it comes to "awareness", which is really what you are talking about, thats a game-type depoendant thing that is really hte provance of the next level up-- the game engine.  Different kinds of games need different types of awareness.  Darkstar provides the way to build these grousp in the form of pub/sub channels but it does not istelf specify how these channels will be used.

I just gave a talk today at JavaOne on my game project, a MMORPG skeleton called DarkMMO.  The way DarkMMO handles awarness is this:

(1) The world is broken down into zones (for client convenience more then anything else)
(2) Zones are gridded into cells, where each cell is a square who's width and hieght is the maximal-view distance.
(3) Moving objects broadcast their moves on the channel associated with the cell they are on.
(4) Objects listen for movement packets in the channel for the cell they are on and up to 4 surrounding ones depending on their exact position in the cell and how their view area overlaps neigboring cells.
(5) When an object crosses a cell boundary, the server changes the channels it is subscribed to.


How did you map your MMO? Heights?

as jeff has explained very well, darkstar is really ur best bet.



and if u take a look at the user showcase section of the forum, jeff has been posting updates on his darkMMO project.

Well since we are on the topic already - perhaps you can advise me also. It still seems to me that although Darkstar is massively scalable etc, it is still harder to use than JGN. In my case, I am not building a MMO, but just a regular game with multiplayer support for say a dozen players. It will not even encompass a number of areas as such. It is a strategy game and the maps will not be as large as in MMO.



I was pretty sure that once I get to it, I will use JGN, but decided to still ask you. I am pretty sure frog will advise JGN, and I am very comfortable with that prospect. I am still wondering if jeff would argue that Darkstar outperforms and is easier to use than JGN even in different genres besides MMO-s.

Jeff? :slight_smile:

Mindgamer said:

I was pretty sure that once I get to it, I will use JGN, but decided to still ask you. I am pretty sure frog will advise JGN, and I am very comfortable with that prospect. I am still wondering if jeff would argue that Darkstar outperforms and is easier to use than JGN even in different genres besides MMO-s.


ive tried both JGN and darkstar, i would say JGN is definitely easier to use. but when it comes to scalability and persistence, darkstar is for sure the winner.