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