[229] | 1 | // |
---|
| 2 | // C++ Interface: Client |
---|
| 3 | // |
---|
[285] | 4 | // Description: |
---|
[229] | 5 | // |
---|
| 6 | // |
---|
[230] | 7 | // Author: Oliver Scheuss, (C) 2007 |
---|
[229] | 8 | // |
---|
| 9 | // Copyright: See COPYING file that comes with this distribution |
---|
| 10 | // |
---|
| 11 | // |
---|
| 12 | |
---|
| 13 | #ifndef NETWORK_CLIENT_H |
---|
| 14 | #define NETWORK_CLIENT_H |
---|
| 15 | |
---|
| 16 | #include <string> |
---|
| 17 | |
---|
[285] | 18 | #include "ClientConnection.h" |
---|
| 19 | #include "PacketManager.h" |
---|
[413] | 20 | #include "GameStateClient.h" |
---|
[496] | 21 | #include "orxonox/core/CoreIncludes.h" |
---|
[459] | 22 | //#include "NetworkFrameListener.h" |
---|
[229] | 23 | |
---|
| 24 | |
---|
| 25 | namespace network{ |
---|
| 26 | |
---|
[459] | 27 | |
---|
| 28 | |
---|
[229] | 29 | /** |
---|
[459] | 30 | network::Client *client; |
---|
[229] | 31 | * The network/Client class |
---|
| 32 | * This class implements all necessary function for the network communication |
---|
| 33 | * It is the root class of the network module |
---|
[285] | 34 | * |
---|
[229] | 35 | */ |
---|
| 36 | class Client : PacketDecoder{ |
---|
| 37 | public: |
---|
| 38 | Client(); |
---|
| 39 | Client(std::string address, int port); |
---|
| 40 | Client(const char *address, int port); |
---|
[285] | 41 | |
---|
[229] | 42 | bool establishConnection(); |
---|
| 43 | bool closeConnection(); |
---|
[285] | 44 | |
---|
[229] | 45 | bool sendMouse(double x, double y); |
---|
| 46 | bool sendKeyboard(char key_code); |
---|
[438] | 47 | bool sendChat( std::string message ); |
---|
[285] | 48 | |
---|
[229] | 49 | bool addMouse(double x, double y); |
---|
| 50 | bool addKeyboard(char key_code); |
---|
[285] | 51 | |
---|
[369] | 52 | bool sendPackets(); |
---|
| 53 | |
---|
[459] | 54 | void tick(float time); |
---|
[285] | 55 | |
---|
[229] | 56 | private: |
---|
| 57 | ClientConnection client_connection; |
---|
| 58 | PacketGenerator pck_gen; |
---|
[413] | 59 | GameStateClient gamestate; |
---|
[229] | 60 | bool isConnected; |
---|
[369] | 61 | |
---|
| 62 | // implement data processing functions of PacketDecoder |
---|
[405] | 63 | void processGamestate( GameStateCompressed *data); |
---|
[400] | 64 | void processClassid(classid *clid); |
---|
[425] | 65 | void processChat( chat *data); |
---|
[229] | 66 | }; |
---|
| 67 | |
---|
[459] | 68 | |
---|
[229] | 69 | } |
---|
| 70 | |
---|
| 71 | #endif |
---|