NetworkDesign: Difference between revisions
Content deleted Content added
imported>Hendrik Brummermann |
imported>Javydreamercsw m Updated links to point to Git repository instead. |
||
| (48 intermediate revisions by 4 users not shown) | |||
Line 1:
{{Navigation for Marauroa Top|Internals}}
{{Navigation for Marauroa Developers}}
Please note: This page explains the low level network communication. You
==Messages==
Marauroa uses messages to communicate between client and server. The messages sent from the client to the server are prefixed with C2S and the ones sent from the server to the client use the prefix S2C.
Each message is implemented in its own Java class in the package marauroa.common.net.message. You can lookup up the details about every message in the [http://
There are for different client states of the game: connected, logged in, in game, logged out. Depending on the state different messages are valid:
Line 18:
The login process is a bit complicated because of security requirements. Don't be scared, just follow it step by step.
Onces the TCP connection is established the clients requests the RSA public key from the server using [
The client now computes a nonce (a random number) and sends its hash as byte array to the server in a [
Almost there: The client has now all the information it needs to actually send the [
The [
If the username/password combination, however, is correct then the Server must send a [
{{br}}
Line 33:
[[Image:messages-loggedin.png|thumb|Selecting a character and transmitting world meta data.]]
The logging in stuff was complicated. But luckily things are getting much easier now. After the login completed successfully the server sends a [
Directly afterwards a [
Now the client picks one of the offered characters. Games that do not support multiple characters can pick the one that matches the account name. The choice is transmitted to the server using a [
The server will check the selected character and reply for a [
If the selection, however, was successful, a [
{{br}}
Line 47:
[[Image:messages-game.png|thumb|Messages sent while the game is active.]]
==== Regular Messages ====
The [https://sourceforge.net/p/arianne/marauroa/ci/master/tree/src/marauroa/common/net/message/MessageS2CPerception.java S2CPerception] message is a message sent from the server to the client to notify the client about changes to the objects that exist near it. The message is based on the idea explained in the [[RolePlayingDesign#Perceptions|Delta Perception]] document.
The message is composed of:
* A type that can be DELTA or TOTAL
* A string indicating the name of the zone the perception is related to.
* A time stamp value that will be just one unit bigger than the previous perception
* A List of RPObject that contains added object
* A List of RPObject that contains modified added object attributes
* A List of RPObject that contains modified deleted object attributes
* A List of RPObject that contains deleted object
* A RPObject that describes the things the rest of players don't see about OUR own object.
Read the Delta perception algorithm to understand what it is for.
The client sends [https://sourceforge.net/p/arianne/marauroa/ci/master/tree/src/marauroa/common/net/message/MessageC2SKeepAlive.java C2SKeepAlive] messages regularly. If there has been no keep alive message for some time, the server will timeout the client.
==== Static Content Transfer ====
Perceptions are about dynamic content. But most games have some static data, too. Like maps, tilesets, sounds. The RPManager keeps track of situation in which the client might need some of this static data. A common case is the movement of the client from one zone to another.
If the RPManager detects such a situation, it will offer the new content to the client using a [https://sourceforge.net/p/arianne/marauroa/ci/master/tree/src/marauroa/common/net/message/MessageS2CTransferREQ.java S2CTransferREQ] message. The message is composed of an array of [https://sourceforge.net/p/arianne/marauroa/ci/master/tree/src/marauroa/common/net/message/TransferContent.java TransferContent] objects containing the name of each resource, its timestamp (or checksum) and if the resource is cacheable or not.
The clients replies with a [https://sourceforge.net/p/arianne/marauroa/ci/master/tree/src/marauroa/common/net/message/MessageC2STransferACK.java C2STransferACK] acknowledging the offer. The message is composed of an array of TransferContent objects containing all the name of each resource and a flag indicating ack or not. Note: The C2STransferACK message is always sent, even if all flags indicate that no transfer should take place.
If the clients has acknowledged the need for content to be transfer, the server sends a [https://sourceforge.net/p/arianne/marauroa/ci/master/tree/src/marauroa/common/net/message/MessageS2CTransfer.java S2CTransfer]. The message contains a again an an array of TransferContent objects. This time, however, the actual data is included as well.
==== Actions ====
Actions are commands sent from the client to the server using a [https://sourceforge.net/p/arianne/marauroa/ci/master/tree/src/marauroa/common/net/message/MessageC2SAction.java C2SAction] message. Example for commands are "move to the right", "look at that object", "attack that rat". It is up to the server to decide whether to execute the action or reject it.
{{br}}
Line 55 ⟶ 89:
If the player is in some kind of combat it is often desirable to prevent him from saving his live by logging out. Therefore the client sends a logout request to the server and the game server can decide whether to accept or reject it. Of course the user can close the client window or force a disconnect of his Internet connection. But in these cases he will simple stay in a game unattended until the timeout anyway.
The clients indicates that it wants to finish the session by sending a [
The server can reply with a [
{{br}}
Line 71 ⟶ 105:
* Timestamp (4 bytes)
This header is followed by message specific data. Have a look at the [
==Network Manager==
Line 122 ⟶ 156:
[[Category:Marauroa]]
{{#breadcrumbs: [[Marauroa]] | [[Navigation for Marauroa Developers|Internals]] | [[NetworkDesign|Network Design]] }}
| |||