NetworkDesign: Difference between revisions
Content deleted Content added
imported>Hendrik Brummermann No edit summary |
imported>Hendrik Brummermann No edit summary |
||
Line 2:
{{Navigation for Marauroa Developers}}
Please note: This page explains the low level network communication. You don't need to bother with these implementation details if you want to use Marauroa to write a game. We document the network design anyway for contributor to Marauroa itself. And it is helpful for people porting Marauroa to other programming languages.
Line 17 ⟶ 15:
[[Image:messages-connected.png|thumb|Messages used to securely login.]]
{{br}}
=== State logged in ===
[[Image:messages-loggedin.png|thumb|Selecting a character and transmitting world meta data.]]
{{br}}
=== State in game ===
[[Image:messages-game.png|thumb|Messages sent while the game is active.]]
{{br}}
=== Logging Out ===
Line 30 ⟶ 31:
[[Image:messages-logout.png|thumb|The client sends a logout request and the server accepts or denies it.]]
{{br}}
== Transmitting Messages over TCP ==
The idea behind arianne's network protocol is to use a single stream of TCP packets between the server and the clients. Different kinds of in-game actions create different types of messages that are then interpreted at the opposite side in to meaningful data.
Line 78 ⟶ 79:
* Finalizing the manager
The read operation is a blocking type operation so we have two options, either
We choose
▲We choose Blocking because we don't want to waste CPU time Polling the network for messages, we just want to sleep until messages are available. Hence we create a Thread to read from the Network, let's call it Network Manager Read.
Writing messages to the network can be simply coded as a method of Network Manager, as write is an operation that is non blocking by nature.
The
To encapsulate all this we create both the Read and Write methods as inner classes of Network Manager.
Line 107 ⟶ 106:
{
get from pendingToSendMessages
send socket
}
Line 115 ⟶ 114:
As you can see, messages are stored in a list when they are received. Hence access to the list must be synchronized.
Now lets get back to the interface as exposed to other objects. The
The
That is the basic idea of the Network Manager
| |||