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