Where to start

Hi all networked monkeys!!!



I’ve begun documenting myself in networked applications and first my attention was cought by RedDwarf Server.

But unfortunately this MMOG server is going to be unsupported by the core development group.



That was an extremely performant networking engine but IMHO isn’t too god to begin developing an application with a near-death framework. So i decided to start develing with spiderMonkey but the tutorials aren’t enough to understand how to use it…



So the question is: where is a good point to start understanding that API?



Thanks a lot :slight_smile:

The best overview written so far is the doc covering the transition from the old API to the new one:

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:networking



It’s not great but it’s a start. I know someone was updating the tutorials but I don’t know how far they got… the wiki currently has some bugs that make me want to break things so I’ve been dragging my feet contributing there.



Perhaps the best way to get a foot in the door is to look at the TestChatClient and TestChatServer in the JME tests. It shows how to setup a basic network client and server and how to send messages as both TCP and UDP.

I’ve seen all the example but it is really hard understand what to do with too many things that are only coded in few examples…



TestCahtClient and TestChatrServer are only the peak of the iceberg and there isn’t another clear example that teaches how to get in with networking…

For the start, i wanna realize a client-server reliable architecture where in a “level” (such as the town.zip map) two player are syncronized and can see each other moving in the level.



For the local player it’s good a simple physicsCharacterControl and for the remote player a “Sinbad” that moves dependig on the remote player.



How can i do this?

SpiderMonkey will help you manage sending and receiving of messages and help you keep track of per-player data on the server but the rest is sort of up to you. I know there was an object syncing example some time back but I don’t remember if it was ported to the new API (I didn’t do it).



There are dozens of ways to architect this sort of thing depending on the type of game you are writing. If it leans more towards the first person shooter and/or real time variety, then these articles give a pretty good foundation in the general ideas:

http://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking

http://developer.valvesoftware.com/wiki/Latency_Compensating_Methods_in_Client/Server_In-game_Protocol_Design_and_Optimization



For something more like WoW, your messaging and state updates can be simplified somewhat but then you are also handling more client-side prediction.



Once you figure out what messages you need to be sending then SpiderMonkey will make sure they get to where they are going and help you handle them when received. But right now it’s up to your game what gets sent.



If you want an example of one way to do networking then you can also look at MonkeyZone. It has a working network layer that uses SpiderMonkey.

Ok, MonkeyZone is a good point to start, but IMHO is like learning to walk starting with a 40km run…



It could be done, but the time is really bigger than starting crawling and then walking…



What i’m looking for is a simple tutorial that teaches what is necessari in a networked game and how to implement it. How to use messges and how to create those based on my need. But all this information are missing in the tutorial series and starting with a port of the api, some BASIC examples and a complex source code is a difficult quest XD



So i think that, like other topics, is needed a HelloNetwork serie that explains in detail how to start with networking and how to implement custom architectures that can be scalable and customizable. SpiderMonkey rely on a Message-Driven updated and syncronized system so it is not the best way tring to implement a custom communicating world that uses for example byte-arrays like RedDwarf.



What i need is only a document like this: http://sourceforge.net/apps/trac/reddwarf/wiki/ServerTutorial

for the client and server and something that explains how to customize masseges that can manage Physics and Graphics wolrds :slight_smile:



Thanks a lot for your patience, but i think that something like this will give a boost in learing SpiderMonkey and (despite my horrible english XD) what i’m tring to do is to give an advice on how to improve this fantastic project



:slight_smile:

Yes, but Red Dwarf is an entire MMO-style game engine… not just a networking API. It makes a lot of assumptions about the kind of game you will be implementing… for example, you could never write an FPS with Red Dwarf.



SpiderMonkey (in this case) wouldn’t even come in until the "Lesson 6: Hello Channels! Coding HelloChannels Running HelloChannels " sections.



…and for some reason, I can’t even link to those from that page so I don’t know what that documentation looks like or it was even written. I’m making assumptions that channels are like network communication channels or something.



Sending raw byte arrays is kind of crude, though, if I’m reading what you are saying right. At some point you end up turning them back into Objects or something I would think… in SM you can just send the objects. But if sending byte arrays is really what you want to do then you can just create a single Message class with a byte[] field and send that.



There are definitely room for some more SpiderMonkey tutorials… but beyond “this is how you create your own custom message type and handle it” it starts to become very game specific. I’m trying to even think how I would phrase a simple shared state example but I can already think of three different ways I’d do it depending on the game I was trying to write.

pspeed said:
but beyond "this is how you create your own custom message type and handle it" it starts to become very game specific. I'm trying to even think how I would phrase a simple shared state example but I can already think of three different ways I'd do it depending on the game I was trying to write.

I haven't touched networking yet (and undoubtedly won't for quite a while), but if there's something I'd like to see is generic examples for some types of games.

FPS, RTS, TPS, that kind of thing. On the other hand, even a generic tutorial from one person could be so different than one from another person. And in both cases, both ways could be right, efficient and working perfectly... So... *shrug*. ;)

So yeah. Two irrelevant posts in 2... Good average. Maybe I should go to bed.

Heheh. But you bring up a good point… or rather reinforce the point. Even just within FPS there are several ways to skin this particular cat… even within just the documents about the source engine there are several trade-offs and tweaks that could make one engine vastly different from another and still essentially be doing what the source engine does.



Throw something like an “Entity System” (http://entity-systems.wikidot.com/) into the mix and it changes the picture completely.



Lose some of the real time requirements of an FPS and you shift the work load around to different code and the messaging scheme looks different.



If you want your messages to get where they are supposed to go as fast as possible and in a stable code base then Spider Monkey will do that for you… and that alone is a non-trivial problem to solve well. Everything else would be built on top of that.



We could definitely use some more concrete examples but someone needs to write them. And because of how interdependent things are, they start to look like MonkeyZone in “complexity”. So it’s not just about the example code but documenting all of the steps to getting there, too. A pretty sizable effort if someone wants to tackle it.

redDwarf is desined to be a server for intense networked games and can suppurt any kind of game such as MMO-FPS or MMO-RPG,l but it isn’t the point.



My intent is not to communciate with byte arrays, taht was only an example, i wanna use SpiderMonkey, but what i’m tring to say is that there is not something that can teach how to use SM’s API in a correct way.



Without taking into account architecture optimization, my problem is that i don’t not even know what have to be used to create a server-client game because there are only some king of messageListener and Network.createServer or Network.connectClient examples in the test folder…



IMHO it is necessary a little explanation on how to use SpiderMonkey with an overview on how to implement a basic communicating system before to read coed-examples like MonkeyZone…



I state that i am a junior Java EE analist and programmer without a many years of java experience, but i’ve studied alone (and now i’m using them) frameworks such as spring, hibernate, struts &Co… that are provided with books, documentation and examples. So i think that to understand something like those frameworks without a deep documentation is really an hard task…



The code is not enough to a junior like me…



To me jMonkey is the BEST_FUC*********ING_THING_EVER_IN_THE_WORLD!!! And my desire is to master it like all developer that contribute to it. And when i’m enough capable, maybe i can give an hand :wink:

kazeshiro said:
redDwarf is desined to be a server for intense networked games and can suppurt any kind of game such as MMO-FPS or MMO-RPG,l but it isn't the point.


Just a correction... since (last I looked anyway) RedDwarf only supports TCP and not UDP, it limits it to games that don't require "twitch"... so FPS is sort of out of the question... at least to the current expected standards for such a game.

re: SM, you are right that it needs more tutorials. But you also may be expecting it to do more than it does. We could (and probably should) write a tutorial to go with the test chat client and server and that would cover 90% of what you'd need to know about the SM API. The only thing it misses is the use of session data... and I may be misremembering. Maybe it is using session data, too.

It's worth doing, though. It will probably be a while before _I_ write such a thing as the wiki has some bugs and likes to chew up text and spit it out funny right now and that makes me want to gouge my eyes out.

Ok, ehmm… The last sentence is too difficult for my english XD



However… Can any one of you write the simplest test that syncronize 2 clients with a server where 2 “Sinbad” players can move and all clients can see this movement?



Thnx a lot!!!

kazeshiro said:
Ok, ehmm.... The last sentence is too difficult for my english XD

However.. Can any one of you write the simplest test that syncronize 2 clients with a server where 2 "Sinbad" players can move and all clients can see this movement?

Thnx a lot!!!

.. Thats called a synchronization system .. SpiderMonkey by itself can't do it for you. You will need some API to handle that task.
I do have something in one of my projects however I don't think it is quite ready for public use

But then what can do SpiderMonkey? This is the simplest thing that a network system can do and maybe is the first reason to use a network engine…

And what about if the client give a message every time there is a movement or a general action? Can it be done in this way?



If SM can’t do this, what have i to use to carry out this task?

The simplest thing that a network system can do is get messages to where they are supposed to go as quickly and reliably as possible without sacrificing the stability of your application. And that’s pretty hard… do not underestimate the complexity of just getting that part right.



On top of that, you can send any kind of message whenever you want… and you can broadcast them out to all players.



But here’s the problem… the simplest scheme: (this presumes some kind of first person camera)



On update() send the camera position and orientation in a message with the client ID. Have a listener on the server that just broadcast()s it to the other connected clients.



A message listener on the client enqueues a Callable implementation containing the message. This callable implementation can look up a Sinbad node based on the client ID and create one if it doesn’t exist. Then it can set the position and orientation of the sinbad node.



Now you have network synchronization.



The problem is that next you’ll want to know how you can make it less jerky. Or how to deal with lag, dropped packets, etc… and there are many different solutions to those problems. Client side prediction, server side prediction… and it depends on what you’re making. But the above will network your game with a minimum amount of code.



JME/SpiderMonkey will probably get a general object sync system at some point that will be pretty good. @momoko_fan has gotten good results from his. But it’s a decent amount of work to maintain something like that and it’s probably not a one size fits all solution.

Mmmm… Ok, i got it…



Finally, what it your best advice to carry out something like that sistem?



What is the best start pont to implement this architecture?

I may have missed it before…



What kind of game are you making?

SpiderMonkey, or any networked communication scheme for that matter, is only a way to exchange data between a server (sometimes servers) and one and more clients by way of a defined protocol.



What you do with the data is up to you. SpiderMonkey won’t “synchronize data between players and a server” by itself. All it is mean to be is a way for a client to take a bunch of information and send it somewhere. That is all.



What you do with said information is out of scope with SpiderMonkey itself.



For example, when Client A walks 10 feet in direction X and Client B walks in direction Y, each client sends this information to the server on a certain protocol (which you’ll have to decide). Usually the server might receive that information and do something about it. What it does with it is completely up to you. It might, for example, check for the validity of A’s distance covered (if it’s too fast, it could be caused by lag, hack or whatever) and the server might act, or not, on this. The server might also take that information and send it to Client B effectively saying: “Client A has moved X units in X direction.”. What the server does and doesn’t do is up to you.



In short, SpiderMonkey is just a simple way to communicate between computers, nothing else.

To tell the true my game isn’t a game… Now i’m trying to write little pieces of documentation explaining how to use JME to help other friends of mine using this beatiful game engine.



But before to do this i have to understand the most difficult aspects of the engine that, IMHO, are:

Physics,

Networking,

Shaders and advanced graphics.



I have a little experience with bullet physics in C++ and now i’ve tried to achieve some difficult tasks with physics but all in all i’ve seen how to do many things and before going more in deep i want to see other aspect of JME.



I have also a little experience with redDwarf and , for my porpose, i have to translate this experience in SpiderMonkey.

For a good start, the first task i want to implement is the example i provived with the 2 client, though in my dreams i wanno do some kind of FSP but in a fantasy style…



However the first thing to implement is 2 clients that are sincronized trough a server.

The next task is to sync different clients in differnt “channels” (i don’t know how to call it with SpiderMonkey kinds of communication, in RD channel are some kind of rooms for a fps ) and , maybe i’m in wrong, for this i’ve to use filters.



With those assumption, what is the best approach from masters of JME? :wink:



PS:

I hope that when i’m enough experienced with JME, i will contribuite to the development of it and, who knows, maybe i’ll improve SM XD

kazeshiro said:
I have also a little experience with redDwarf and , for my porpose, i have to translate this experience in SpiderMonkey.


Ok, but remember: Red Dwarf is a full client/server architecture including persistence, object management, etc.. It's not a networking API.

kazeshiro said:
For a good start, the first task i want to implement is the example i provived with the 2 client, though in my dreams i wanno do some kind of FSP but in a fantasy style..


FPS helps narrow it down... though first person shooters have requirements that make them the trickiest to implement a network sync for. Please read the documents I linked on how Valve does it and you'll understand why this is tricky.

kazeshiro said:
However the first thing to implement is 2 clients that are sincronized trough a server.
The next task is to sync different clients in differnt "channels" (i don't know how to call it with SpiderMonkey kinds of communication, in RD channel are some kind of rooms for a fps ) and , maybe i'm in wrong, for this i've to use filters.


How you "zone" your game depends on the game requirements, the level design, etc.. Once you've done that, it's up to your server code to decide which connections to send the messages to or which updates to send. For example, simple channel based messages may not be the best way for an FPS. There will be a lot of overlap in state and so a user in one room may get some of the same state as the user in the room right next to them. Whether you batch state by room or by user depends on the size of the expected state to send and other factors. For example, if you are trying to support poorer connections then you might batch state based on priority and in that case it might be better to batch it up per user. From a serialization/networking efficiency standpoint, it would be better to batch by room and then send the relevant room state as separate messages to the users who are in or near that room.

But the concept of channels is sort of arbitrary.

And what about this?

kazeshiro said:

However the first thing to implement is 2 clients that are sincronized trough a server.