[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 | |
---|
[673] | 13 | #ifndef _Client_H__ |
---|
| 14 | #define _Client_H__ |
---|
[229] | 15 | |
---|
| 16 | #include <string> |
---|
| 17 | |
---|
[777] | 18 | #include "NetworkPrereqs.h" |
---|
[285] | 19 | #include "ClientConnection.h" |
---|
| 20 | #include "PacketManager.h" |
---|
[413] | 21 | #include "GameStateClient.h" |
---|
[459] | 22 | //#include "NetworkFrameListener.h" |
---|
[229] | 23 | |
---|
| 24 | |
---|
[777] | 25 | namespace network |
---|
| 26 | { |
---|
| 27 | /** |
---|
[459] | 28 | network::Client *client; |
---|
[777] | 29 | * The network/Client class |
---|
| 30 | * This class implements all necessary function for the network communication |
---|
| 31 | * It is the root class of the network module |
---|
| 32 | * |
---|
| 33 | */ |
---|
| 34 | class _NetworkExport Client : PacketDecoder{ |
---|
[229] | 35 | public: |
---|
[777] | 36 | Client(); |
---|
| 37 | Client(std::string address, int port); |
---|
| 38 | Client(const char *address, int port); |
---|
[285] | 39 | |
---|
[777] | 40 | bool establishConnection(); |
---|
| 41 | bool closeConnection(); |
---|
[285] | 42 | |
---|
[777] | 43 | bool sendMouse(double x, double y); |
---|
| 44 | bool sendKeyboard(char key_code); |
---|
| 45 | bool sendChat( std::string message ); |
---|
[285] | 46 | |
---|
[777] | 47 | bool addMouse(double x, double y); |
---|
| 48 | bool addKeyboard(char key_code); |
---|
[285] | 49 | |
---|
[777] | 50 | bool sendPackets(); |
---|
[285] | 51 | |
---|
[777] | 52 | void tick(float time); |
---|
| 53 | |
---|
[229] | 54 | private: |
---|
[777] | 55 | ClientConnection client_connection; |
---|
| 56 | PacketGenerator pck_gen; |
---|
| 57 | GameStateClient gamestate; |
---|
| 58 | bool isConnected; |
---|
[229] | 59 | |
---|
[777] | 60 | // implement data processing functions of PacketDecoder |
---|
| 61 | void processGamestate( GameStateCompressed *data); |
---|
| 62 | void processClassid(classid *clid); |
---|
| 63 | void processChat( chat *data); |
---|
| 64 | }; |
---|
[459] | 65 | |
---|
[777] | 66 | |
---|
[229] | 67 | } |
---|
| 68 | |
---|
[673] | 69 | #endif /* _Client_H__ */ |
---|