1 | // |
---|
2 | // C++ Interface: Client |
---|
3 | // |
---|
4 | // Description: |
---|
5 | // |
---|
6 | // |
---|
7 | // Author: Oliver Scheuss, (C) 2007 |
---|
8 | // |
---|
9 | // Copyright: See COPYING file that comes with this distribution |
---|
10 | // |
---|
11 | // |
---|
12 | |
---|
13 | #ifndef _Client_H__ |
---|
14 | #define _Client_H__ |
---|
15 | |
---|
16 | #include <string> |
---|
17 | |
---|
18 | #include "NetworkPrereqs.h" |
---|
19 | #include "ClientConnection.h" |
---|
20 | #include "PacketManager.h" |
---|
21 | #include "GameStateClient.h" |
---|
22 | //#include "NetworkFrameListener.h" |
---|
23 | |
---|
24 | |
---|
25 | namespace network |
---|
26 | { |
---|
27 | /** |
---|
28 | network::Client *client; |
---|
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{ |
---|
35 | public: |
---|
36 | Client(); |
---|
37 | Client(std::string address, int port); |
---|
38 | Client(const char *address, int port); |
---|
39 | |
---|
40 | bool establishConnection(); |
---|
41 | bool closeConnection(); |
---|
42 | |
---|
43 | bool sendMouse(double x, double y); |
---|
44 | bool sendKeyboard(char key_code); |
---|
45 | bool sendChat( std::string message ); |
---|
46 | |
---|
47 | bool addMouse(double x, double y); |
---|
48 | bool addKeyboard(char key_code); |
---|
49 | |
---|
50 | bool sendPackets(); |
---|
51 | |
---|
52 | void tick(float time); |
---|
53 | |
---|
54 | private: |
---|
55 | ClientConnection client_connection; |
---|
56 | PacketGenerator pck_gen; |
---|
57 | GameStateClient gamestate; |
---|
58 | bool isConnected; |
---|
59 | |
---|
60 | // implement data processing functions of PacketDecoder |
---|
61 | void processGamestate( GameStateCompressed *data); |
---|
62 | void processClassid(classid *clid); |
---|
63 | void processChat( chat *data); |
---|
64 | }; |
---|
65 | |
---|
66 | |
---|
67 | } |
---|
68 | |
---|
69 | #endif /* _Client_H__ */ |
---|