= Network = == Overview == The image below displays the basic concept of the Network Engine: [[Image(conceptoverview.png, 78%)]] The basic jobs of the Network Engine are: * Synchronise all objects of the universe between server and clients * Provide a chatting mechanism * Transmit all neccessary information about the players (nickname, score, ...) The server and client components manage all the other network components. They call all necessary functions every network tick (not exactly the same as a game tick). == Components == This is a description of the important network components and/or classes: || '''Component''' || '''Description''' || '''Classes included''' || || [wiki:network/Host Host] || Interface class of the Network Engine || Host, Server, Client, ClientInformation || || [wiki:network/Synchronisable Synchronisable] || Interface class for all network objects, that need synchronisation || Synchronisable || || || '''internal components''' || || || [wiki:network/Gamestate Gamestate] || Management of the object information to be synchronised || GamestateHandler, GamestateManager, GamestateClient || || [wiki:network/Packet Packet] || Management of the data to be transmitted || Packet, Acknowledgement, Chat, ClassID, DeleteObjects, Gamestate, Welcome || || [wiki:network/Connection Connection] || Management of the network connection between server and client || ConnectionManager, ClientConnection || == External API == === Synchronisable === The [wiki:network/Synchronisable Synchronisable] class is a base class of all Objects that need to be synchronised (e.g. SpaceShip, Model, Projectile, etc.). It is the interface between the ObjectHierarchy and the Network Engine. For more information about this go [wiki:network/Synchronisable here]. === Host === The [wiki:network/Host Host] class is the Base class of the Server and Client classes. It provides some static functions: * network::Host::running(): return true, if a server or client is running * network::Host::getPlayerID(): returns the player id of a client (this is only a temporary hack until we have a PlayerManager) * network::Host::getShipID(): return the objectID of the players ship (also a temporary hack) * network::Host::isServer(): return true/false (whether we are in server/client mode) * other functions (not really meant to be used outside the network engine) == Overview Internal Dataflow through the Network Engine ('18) == [[Image(network_overview.png, 78%)]] A Synchronisable is a class, which is going to be synced with the server. A Synchronisable contains several variables (A ship would have its position and speed as synchronised variables). All of the Classes registered as Synchronisable with its variables are collected by GamestateClient, and are packed in a Gamestate. A Gamestate is basically a list of all Synchronisables. The Gamestate is then compressed and sent by ClientConnection as a packet to the server. GamestateManager also receives new Gamestates from the server, which gets decompressed, unpacked and sent to the client game. This process syncs all Synchronisables to the server.