1
\$\begingroup\$

I have high experience In Java and Networking. Our team have built a effective server that can create thread-pools managing many players. But we have hit a brick-wall. The way our server works is that our clients directly all just connect to the server. The client sends information to the server. For example, Client 004 pressed W. And the server calculates and responds. But here's the problem. What exactly do we send over the data stream? Do we send strings and decode them on the client/server side, or serialize objects? Sadly that question is very opinion based. So let me re-phrase it. What data do we send over the stream? For example, you can use W,A,S,D To move around. Im guessing it should look like this.

User Pressed W > Client sends string saying w to server > Server calculates movement > Server sends string saying player position to player > User updates players position.

But then we have to render other players. So we thought about this

User MPressed W > Client sends string saying W to server > Server calculates movement > Server checks if any others players are in the area > Server saves data of all players and yourself into a string and adds positions and sends to client.

Fair enough. But imagine if the server had to send over information, like the other players clothing, their health, mana, position, current animated frame.

The string might look like this:

"Bob, 12, 321, 391.34, 2914.2, Left, 0, False, null, null, sword, null, null"

Just for one player! To be sent over. The string concept is becoming long and tedious.

I have re-wrote this several times. And I still do find it confusing to understand the question myself.

But to shorten it down. How do I create a system where its a mmo really.

We've created the server, client art. We've payed for a large server with ddos protection. But we don't know what to send over the sockets.

\$\endgroup\$
1
\$\begingroup\$

What if I want to use the arrow keys? It'd be crap.

You have the clients send updates like "I am at x moving at speed p and turning at rate m"

The server should so some quick bounds checking (to prevent cheating) then pass those updates on ASAP.


Clients should query what they need, for example "get player list" (as some command) might cause the server to send back a list (in whatever) format of the players AND their positions

The client will then be like Alec is closest, followed by Bob and be like:

> Describe Alec
< Health: 100, max health 120, clothes.....
> Describe Bob
< (so forth)

Obviously don't send these as strings. State machines and UDP are the way to go.

Like expect 4 bytes to be some sort of "command ID", if the command ID is 13 (get player list) then expect 2 bytes (the number of players, unsigned int) then expect 3 floats, a number for the length of the name and that length number of bytes. - do this for each player.

\$\endgroup\$
  • 1
    \$\begingroup\$ But you should never trust the client to handle anything! Not a single mathematical operation! \$\endgroup\$ – user72681 Sep 27 '15 at 16:44
  • \$\begingroup\$ @ElliotBewey the client should be doing stuff like that. Otherwise you can't really expect even 2 frames per second. Quite often on online FPSes two people will shoot each other, consequences of special relativity. \$\endgroup\$ – Alec Teal Sep 27 '15 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy