NetworkDesign: Difference between revisions

Content deleted Content added
imported>Hendrik Brummermann
some cleanup
imported>Hendrik Brummermann
No edit summary
Line 97:
 
==Message Types==
ToMarauroa uses messages to communicate, thebetween Clientclient and Serverserver. ofThe Marauroamessages usesent afrom streamthe ofclient UDPto packets.the Theserver messageare systemprefixed belongswith toC2S and the marauroa.common.netones package,sent sofrom referthe server to the codeclient foruse athe detailed knowledge of theprefix systemS2C.
 
Each message is implemented in a java class in the package marauroa.common.net.message. You can lookup up the details about every message in the [http://stendhal.game-host.org/hudson/job/marauroa_HEAD/javadoc/marauroa/common/net/message/package-summary.html javadoc]. If you want to port Marauroa to another programming language, you will need know how the message are serialized exactly. The easiest way to learn that is to look at the [http://arianne.cvs.sf.net/viewvc/arianne/marauroa/src/marauroa/common/net/message source code] of the readObject() and writeObject() methods.
We have Client to Server, aka C2S, and Server to Client, aka S2C, messages. <br>
Most messages have two versions of themselves: the C2S and S2C versions.
 
There are for different client states of the game: connected, logged in, in game, logged out. Depending on the state different messages are valid:
Communication Model
<pre>
Client Server
------ ------
--Anytime:
Send C2S Login Request Key Send S2C Send Key
--onConnect:
Send C2S Login Promise Send S2C Send Nonce
Send C2S Login Send Nonce
Name and Password If C2S Login is correct
Send S2C Login ACK
else
Send S2C Login NACK
end if
 
== State connected ==
Send S2C Character List
 
[[Image:messages-connected.png]]
Send S2C Server Info
 
== State logged in ==
Send Choose Character If character is correct
Send Choose Character ACK
else
Send Choose Character NACK
Finish
 
[[Image:messages-loggedin.png]]
--onTimer:
Send Perception ACK Send Perception
 
== State in game ==
--on RPManager request:
Send TransferREQ
Send TranferACK
Send Transfer
 
[[Image:messages-game.png]]
--onEvent:
Send Action Send Action ACK
 
== Logging Out ==
--onExit:
Send Logout If Client can logout
Send Logout ACK
else
Send Logout NAC
</pre>
 
[[Image:messages-logout.png]]
Let's discuss in detail each message type.
 
===Message C2S Login Request Key===
This Login Message is sent from the Client to the Server to request the RSA public key of the server.
 
===Message S2C Login Send Key===
This Login Message is sent from the Server to the Client in response to a key request. It is composed of two bytes arrays. The first one contains the value of 'n', and the second the value of 'e'.
 
===Message C2S Login Promise===
This is the first real action of authentification from the client. It computes a nonce (a random number) and sends a hash of its nonce to the server. This message contains the hash as a bytes array.
 
===Message S2C Login Send Nonce===
The server responds to the client promise by computing a nonce and sending it in this message. This message contains the nonce as a bytes array.
 
===Message C2S Login Send Nonce Name and Password===
The client now sends its nonce, its username and the value Crypt(xor(xor(client nonce, server nonce), password). This message contains 3 fields. The first one is a bytes array containing the client nonce, the second one a string containing the username and the third one a bytes array containing the encrypted password. On reception, the server checks that the hash he received at first is the hash of the nonce he just received. It then decodes the password field, and having the value of the client nonce and its nonce, it gets the value of the password. If the username/password combination is correct then the Server must send a Login ACK Message to indicate to the Client that the message has been correctly processed. However, if the username/password is wrong the Server will send a Login NACK (Not ACKnoledge).
 
===Message S2C Login ACK===
The LoginACK Message is sent from the Server to the Client to indicate that the login process has been completed correctly and that it can proceed to the next step. It has no params.
 
===Message S2C Login NACK===
The LoginNACK Message is sent from the Server to the Client to tell the Client that its login message is incorrect because either the username or password is wrong or because Server has decided to reject the login request, e.g. if the Server is full or because the IP is banned.
 
The message is composed of: Message indicating the resolution.
 
===Message S2C Character List===
The CharacterList Message is sent from the Server to the Client to give the Client a choice of character to play with. This feature models the behavior of having several characters associated with a single account ( see [[DesignOverview#What_is_Marauroa.3F | the Marauroa Feature List]] ).
 
The message is composed of: A List of Character names
 
Each character name must be unique at Server level, and it is assigned when the character is created.
 
===Message S2C Server Info===
The Server Info Message is sent from the Server to the Client to tell the Client about what Server is running, and details on how to inform the Server administrator of any problems (e.g. their email address).
 
The message is composed of: A List of strings of the type "attribute=value"
 
===Message C2S Choose Character===
The ChooseCharacter Message is sent from the Client to the Server to indicate what character the user wishes to play the game with.
 
The message is composed of: the name of the character
 
The name of the character must be one of the names listed in the Character List Message or the Server will reply with a Choose Character NACK message. Once the character has been chosen and the acknoledge has been recieved the Client is ready to start the game.
 
The Server will reply to this message with a Choose Character ACK or a Choose Character NACK message. The Client must have already logged in before receiving this message, if not the Server will send a Choose Character NACK.
 
Once a character is chosen, the only way to choose a new one is by logging out and logging in again.
 
===Message S2C Choose Character ACK===
The Choose Character ACK Message is sent from the Server to the Client to notify the Client that the character has been chosen.
 
The message is composed of: the object.ID of the character
 
We need this value to track our own character.
 
===Message S2C Choose Character NACK===
The Choose Character NACK Message is sent from the Server to the Client to notify the Client that the character has not been chosen. This also implies to the Client that it should send another ChooseCharacter Message.
 
It has no params.
 
===Message C2S Logout===
The Logout Message is sent from the Client to the Server to indicate that it wants to finish the session. It has no params.
 
If the Client can logout the Server will send a Logout ACK Message and the Client can safely close the connection, but if the Server sends a Logout NACK Message, the Client should keep playing as disconnecting at that moment will leave its avatar in the game uncontrolled ( idle ).
 
===Message S2C Logout ACK===
The Logout ACK Message is sent from the Server to the Client to notify the Client that the logout has been accepted.
 
It has no params.
 
===Message S2C Logout NACK===
The Logout NACK Message is sent from the Server to the Client to tell the Client that the logout has not been accepted, possibly because something related to the RP entity, for example, combat is in progress.
 
It has no params.
 
===Message C2S Action===
The Action message is sent from the Client to the Server to notify the Server of the Clients desire to execute an action. The message is simply composed of a single action.
 
===Message S2C Action ACK===
The Action ACK is sent from the Server to the Client to identify that the action has been received in the Server. It doesn't acknowledge that the action has been accepted by the RP Manager, it just means that the action successfully arrived at the Server.
 
It has 1 param: action_id - is used to identify to which action you referred. In Marauroa you can command several actions per turn.
 
===Message S2C Perception===
The Perception 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.
 
===Message C2S Perception ACK===
The perception ACK message is sent from the Client to the Server. We use this message to inform the Server that the Client is still there and listening. It has no params.
 
===Message S2C TransferREQ===
The TransferREQ message is a message sent from the Server to the Client to notify the Client of the server's desire to send content useful for game play.
 
The message is composed of: An array of TransferContent objects containing the name of each resource, its timestamp (or checksum) and if the resource is cacheable or not.
 
===Message C2S TransferACK===
The TransferACK message is a message sent from the Client to the Server to notify the Server about what of the given TransferContent elements recieved from TransferREQ should be sent.
 
The message is composed of: An array of TransferContent objects containing all the name of each resource and a flag indicating ack or not.
 
===Message S2C Transfer===
The Transfer message is a message sent from the Server to the Client to send the Client content useful for the game where play will happen.
 
The message is composed of: An array of TransferContent objects containing all the name of each resource, its timestamp, a flag indicating if the resource is cacheable or not and a byte array with the content itself.
 
[[Category:Marauroa]]