Fundamental networking issues

There’s probably an easy way to do it, but it seems so hard for me to set up a basic multiplayer game. Once I get beyond the networking tutorials I am at a loss for what to do. At first I thought I should store information about my clients (Screen name, character model, items, location) in an array of some kind of ‘clients’ class, but what about when one client disconnects and I’m left trying to send messages to him. I know the client an send me a message to tell me when he is disconnecting but then replacing him in the clients array., What am I supposed to do when the server host wants to kick a client, by his screen name? How do I even do this without breaking all the rules of object oriented programming? I had a look at the MonkeyZone code, but that’s like trying to figure out how to make a brick by staring at a brick wall… I know I must seem a fool as there is obviously an easy way to do this, and I’m not asking for code, just some ideas. This is killing my project as I can’t seem to overcome this boundary, Its grinding to a halt.

Actully i dont exactly get what your problem is? I use a arraylist with clientproxys as well.

Hello,



Well, in a multiplayer game you should really not stick to much with OOP. Dividing each Class into two classes, data and logic (aka EntitySystem) gives you much greater flexibility.



Regarding your issues:

First you probably have to decide what kind of server client relationship you want. Authoritative server or just a synch server. This depends what kind of game you program and how you would like to deal with cheaters.



Kicking players shoudl not be a problem, since spidermonkey already have included functionallity for kicking.-

You should of course keep a list of clients connected to the server. When a player disconnects you simply remove that player from the list. I see no problem there…



Without a specific problem i unfortunatly can’t help you much more.

There is not an easy way to do this.



Think about how hard threading is.



Network programming is like threading programming but with communication latencies and the fact that one thread could disappear at any second…

1 Like

I think a better question to ask would be: What programming/Java concepts should I be comfortable with to make sense of the networking tutorials?



What I’m saying @javagame is that you’ve probably overextended yourself. Networking is something you start playing around with after you’ve done several games.

1 Like

Also, if you register a connection listener: http://hub.jmonkeyengine.org/javadoc/com/jme3/network/Server.html#addConnectionListener(com.jme3.network.ConnectionListener)



You are notified about every new client and every leaving client.



I echo much of what the others are saying, though. Networking is hard. I think anyone capable of dealing with the general (non-JME specific) networking issues will easily be able to get started with just the TestChatClient + TestChatServer and the javadocs. The tutorials are nice to round things out but I almost feel like they make it too accessible sometimes.

1 Like

Alright, thanks for the advice and tips everyone, but one thing I would like to say, especially to @erlend_sh is when I first downloaded the JMP I didn’t even know what a constructor was, I was doing the art on a game my friend and I were working on and when he left the project I was determined to finish. I learnt how to program with jme from nothing, and I can after 8 months I reckon I can use the majority of jmonkey’s features and end up with a half decent game, and I’m only 15 years old. So I think it can be good to set yourself high standards, try to do something you cant do. Don’t get me wrong, I know you are right, I think i’ll carry on working and come back to networking at a later stage, maybe have a look at some other networking APIs, I have had some success in kicking clients though this afternoon. Thanks, speech over :p.

He he, yeh that’s great, really. High standards are important, we just know that anyone who’s set out to make a game is already setting themselves up for a whole lot of challenges. Networking is for the true masochists or black belts :stuck_out_tongue:

1 Like

Harder than GLSL? It’ll be a while before I have another crack at that…

1 Like
@javagame said:
Harder than GLSL? It'll be a while before I have another crack at that...


Actually way harder,
In GLSL something works, or doesn't work, and it's basically only glsl
In Networking something works, or doesn't work, or works sometimes ;) additionally it includes concurrency, latency, lost packages,
1 Like

Another thing to add - networking is never easy to do…but it’s also far easier to do it badly than it is to do it right…



…and bad networking shows up late, unpredictably - and is basically a nightmare to track down.

@javagame

Maybe this thread can be interesting for you, too. It is a little more on game developing in general. But as you said you just started coding it might be good to look at it.

http://hub.jmonkeyengine.org/groups/jmonkeyplatform/forum/topic/where-to-start-learning/



Concerning the network issue I agree to what @zzuegg and @erlend_sh said. Networking is really tough thing and dependent on how complex your game is. But even for really simple games and even non-realtime games where you do not need to send much data it is still not that easy. One very important thing is the data structure or entity system mentioned above of your game. If that is good networking is directly affected by that. And btw that does not stand in contrast to OOP. It is a common technique to separate absolute data from objects as it makes your application more flexible and with networking you have less data to transfer because you dont have to send the object overhead data that all clients know anyways. You can then build the objects on the other side from the given data. For more information on this look at the Model-View-Controller design pattern (MVC Eng, unfortunately the english article is not as good as the german, but you can do more research on that of course). Best is to only send primitive data types via network.


@javagame said:
So I think it can be good to set yourself high standards, try to do something you cant do. Don't get me wrong, I know you are right, I think i'll carry on working and come back to networking at a later stage...

For sure it is always good to set yourself high goals that is how you learn most. But also can be very disapointing and finally kill your motivation completely. So it is good to break a big project into many small problems and then maybe even start a new project for some issues where you just concentrate on one thing. Like for the network stuff I would make a simple network application and play around with that independently from your main project. And if you think you are expierenced enough adept it to your game. Anyways if you want to have network in your game at any point you should now think about that because refactoring your code and data structure is really hard and time consuming
1 Like
@xeratos said:

For sure it is always good to set yourself high goals that is how you learn most. But also can be very disapointing and finally kill your motivation completely. So it is good to break a big project into many small problems and then maybe even start a new project for some issues where you just concentrate on one thing. Like for the network stuff I would make a simple network application and play around with that independently from your main project. And if you think you are expierenced enough adept it to your game. Anyways if you want to have network in your game at any point you should now think about that because refactoring your code and data structure is really hard and time consuming


Thats exactly what I'm doing,