Changes between Version 2 and Version 3 of code/doc/network/Host
- Timestamp:
- Sep 17, 2008, 4:19:22 PM (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
code/doc/network/Host
v2 v3 3 3 The basic task of these classes is the interface between Orxonox and the network engine. This includes creating and opening a server, connecting to a server as client and provide common functions (for Server and Client) like sendChat. 4 4 5 The Host classis the parent class of Server and Client. It ensures that only one instance of either Server or Client is running (so called Singleton) and provides static functions that both (Server and Client) have to implement.5 Host is the parent class of Server and Client. It ensures that only one instance of either Server or Client is running (so called Singleton) and provides static functions that both (Server and Client) have to implement. 6 6 7 7 == Host class and common functions == … … 10 10 || running() || Tells you whether an instance of Server or Client exists (no Information, wheter connected or not) || 11 11 || isServer() || Tells you whether the instance is a Server or not || 12 || sendChat( unsigned char *message) || Sends a message to the server or the clients ||12 || sendChat(message) || Sends a message to the server or the clients || 13 13 14 14 == Server class == 15 16 15 Obviously this class implements a server. See below for usage.[[BR]] 16 Special functions of Server (not included in Host): 17 || '''Function Name''' || '''Description''' || 18 || Server() || Constructor: sets port to 55556 and binds to all addresses || 19 || Server(int portnr) || Constructor: sets port to portnr || 20 || Server(int portnr, string bindaddress) || Constructor: sets port to portnr and listens to bindaddress || 21 || open() || opens the listener and accepts new connections || 22 || close() || closes the listener || 17 23 == Client class == 24 Special functions of Client (not included in Host): 25 || '''Function Name''' || '''Description''' || 26 || Client() || Constructor: sets destination address and port to localhost|55556 || 27 || Client(string address, int port) || Constructor with user defined destination address and port || 28 || establishConnection() || tries to connect to the server || 29 || closeConnection() || closes the connection || 30 == ClientInformation == 31 This class implements a list with all neccessary information about a client (e.g. network address, port, PlayerID, shipID, gamestateID, ...). It is for internal use only. 18 32 19 33 == Usage Examples == 34 Server usage: 35 {{{ 36 network::Server server(); // this creates the server and sets port and bindaddress to the default values 37 server.open(); 38 }}} 39 Client usage: 40 {{{ 41 network::Client client(address, port); // this creates the client and sets port and dest.address to appropriate values 42 if(client.establishConnection()) 43 ... //success 44 else 45 ... //failure 46 }}}