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