NetworkDesign: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
imported>ToBeFree replacing old links again. This time it was quite a lot of work. xD |
imported>Javydreamercsw m Updated links to point to Git repository instead. |
||
| (6 intermediate revisions by 2 users not shown) | |||
| Line 18: | Line 18: | ||
The login process is a bit complicated because of security requirements. Don't be scared, just follow it step by step. |
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 [ |
Onces the TCP connection is established the clients requests the RSA public key from the server using [https://sourceforge.net/p/arianne/marauroa/ci/master/tree/src/marauroa/common/net/message/MessageC2SLoginRequestKey.java C2SLoginRequestKey]. The server checks the protocol version implicitly included in every message. If it is compatible, it replies with a [https://sourceforge.net/p/arianne/marauroa/ci/master/tree/src/marauroa/common/net/message/MessageS2CLoginSendKey.java S2CLoginSendKey] including the RSA public key. It is composed of two bytes arrays: The first one contains the value of 'n', and the second the value of 'e'. |
||
The client now computes a nonce (a random number) and sends its hash as byte array to the server in a [ |
The client now computes a nonce (a random number) and sends its hash as byte array to the server in a [https://sourceforge.net/p/arianne/marauroa/ci/master/tree/src/marauroa/common/net/message/MessageC2SLoginSendPromise.java C2SLoginPromise] message. The server remembers the client nonce and answers with its own nonce in a [https://sourceforge.net/p/arianne/marauroa/ci/master/tree/src/marauroa/common/net/message/MessageS2CLoginSendNonce.java S2CLoginSendNonce]. |
||
Almost there: The client has now all the information it needs to actually send the [ |
Almost there: The client has now all the information it needs to actually send the [https://sourceforge.net/p/arianne/marauroa/ci/master/tree/src/marauroa/common/net/message/MessageC2SLoginSendNonceNameAndPassword.java C2SLoginSendNonceNameAndPassword]: Its nonce, the username and the value rsaCrypt(xor(xor(client nonce, server nonce), password)). The first field is a bytes array containing the client nonce, the second one a string containing the username and the third one a byte 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. |
||
The [ |
The [https://sourceforge.net/p/arianne/marauroa/ci/master/tree/src/marauroa/common/net/message/MessageS2CLoginNACK.java S2CLoginNACK] message is sent from the server to the client to tell the client that its login request was rejected because the username or password is wrong, the account was banned or the server is full. The included result object will tell which of the cases prevented the login. |
||
If the username/password combination, however, is correct then the Server must send a [ |
If the username/password combination, however, is correct then the Server must send a [https://sourceforge.net/p/arianne/marauroa/ci/master/tree/src/marauroa/common/net/message/MessageS2CLoginACK.java S2CLoginACK] message to tell the client that the message has been correctly processed. It contains information about the last login, so that the user is able to recognize unauthorized usage of his account. The client state is changed to "logged in" in this case. |
||
{{br}} |
{{br}} |
||
| Line 33: | Line 33: | ||
[[Image:messages-loggedin.png|thumb|Selecting a character and transmitting world meta data.]] |
[[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 [ |
The logging in stuff was complicated. But luckily things are getting much easier now. After the login completed successfully the server sends a [https://sourceforge.net/p/arianne/marauroa/ci/master/tree/src/marauroa/common/net/message/MessageS2CServerInfo.java S2CServerInfo] message. It tells the client about what kind of server is running, and details on how to contact the server administrator (e.g. their email address). The message is composed of a List of strings of the form "attribute=value". In addition this message also contains the list of defined RPClasses. |
||
Directly afterwards a [ |
Directly afterwards a [https://sourceforge.net/p/arianne/marauroa/ci/master/tree/src/marauroa/common/net/message/MessageS2CCharacterList.java S2CCharacterList] message is sent from the server to the client. It offers a choice of character to play with. This feature models the behavior of having several characters associated with a single account. Each character name must be unique at server level, and it is assigned when the character is created. |
||
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 [ |
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 [https://sourceforge.net/p/arianne/marauroa/ci/master/tree/src/marauroa/common/net/message/MessageC2SChooseCharacter.java C2SChooseCharacter] message. The name of the character must be one of the names listed in the character list. |
||
The server will check the selected character and reply for a [ |
The server will check the selected character and reply for a [https://sourceforge.net/p/arianne/marauroa/ci/master/tree/src/marauroa/common/net/message/MessageS2CChooseCharacterNACK.java S2CChooseCharacterNACK] if the choice was invalid. This implies that the client should send another C2SChooseCharacter message. |
||
If the selection, however, was successful, a [ |
If the selection, however, was successful, a [https://sourceforge.net/p/arianne/marauroa/ci/master/tree/src/marauroa/common/net/message/MessageS2CChooseCharacterACK.java ChooseCharacterACK] message is sent and the client state changed to "in game". |
||
{{br}} |
{{br}} |
||
| Line 50: | Line 50: | ||
==== Regular Messages ==== |
==== Regular Messages ==== |
||
The [ |
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: |
The message is composed of: |
||
| Line 65: | Line 65: | ||
The client sends [ |
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. |
||
| Line 72: | Line 72: | ||
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. |
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 [ |
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 [ |
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 [ |
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 ==== |
||
Actions are commands sent from the client to the server using a [ |
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}} |
{{br}} |
||
| Line 89: | Line 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. |
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 clients indicates that it wants to finish the session by sending a [https://sourceforge.net/p/arianne/marauroa/ci/master/tree/src/marauroa/common/net/message/MessageC2SLogout.java C2SLogout]. |
||
The server can reply with a [ |
The server can reply with a [https://sourceforge.net/p/arianne/marauroa/ci/master/tree/src/marauroa/common/net/message/MessageS2CLogoutNACK.java S2CLogoutNACK] to reject the logout request. Or it confirms the request with a [https://sourceforge.net/p/arianne/marauroa/ci/master/tree/src/marauroa/common/net/message/MessageS2CLogoutACK.java S2CLogoutACK]. In this case the client state is changed to logged out. |
||
{{br}} |
{{br}} |
||
| Line 105: | Line 105: | ||
* Timestamp (4 bytes) |
* Timestamp (4 bytes) |
||
This header is followed by message specific data. Have a look at the [ |
This header is followed by message specific data. Have a look at the [https://sourceforge.net/p/arianne/marauroa/ci/master/tree/src/marauroa/common/net/message/ source code] of the methods readObject() and writeObject() of the message in question. |
||
==Network Manager== |
==Network Manager== |
||