Recast  1
Game with custom magic
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Server.hpp
Go to the documentation of this file.
1 
11 #ifndef RECAST_SERVER_H
12 #define RECAST_SERVER_H
13 
14 #include <string>
15 #include <thread>
16 #include <world/Box2DWorld.h>
17 #include "threads/InputThread.hpp"
27 
28 class Player;
29 
31 
33 
37 class Server : public ICommandSender {
38 public:
39 
40  Server();
41 
42  ~Server();
43 
44  Server(const Server &other) = delete;
45 
46  void initServer();
47 
48  bool isOP() const { return true; }
49 
50  Server *getServer() { return this; }
51 
52  Player *getPlayer() { return NULL; }
53 
54  void onMessage(const std::string &msg);
55 
56  bool shutdown();
57 
58  bool isRunning() const { return isLaunching; }
59 
60  PlayersOnline *getPlayers() const { return players; }
61 
62  virtual Box2DWorld *getWorld() { return &world; }
63 
64  std::shared_ptr<TempWorld> getTemperatureWorld() const { return temperatureWorld; }
65 
66 private:
67  void initTemperatureWorld();
68 
69  void update();
70 
71  void runNetworkServer(NetworkServer *tcp, NetworkServer *udp);
72 
73  volatile bool isLaunching;
74  std::thread inputThread;
75  std::thread listenTCPThread;
76  std::thread listenUDPThread;
77  PlayersOnline *players;
78  NetworkServer *serverTCP;
79  NetworkServer *serverUDP;
80  InputThread *inputObject;
81  std::shared_ptr<TempWorld> temperatureWorld;
82  std::shared_ptr<IUpdater> temperatureWorldUpdater;
83 
84  Box2DWorld world;
85 };
86 
87 
88 #endif //RECAST_SERVER_H
Main class in Recast Server.
Definition: Server.hpp:37
Definition: ITemperatureWorldChunkableObservable.hpp:42
bool isOP() const
Definition: Server.hpp:48
void onMessage(const std::string &msg)
Definition: Server.cpp:124
void initServer()
Definition: Server.cpp:62
bool shutdown()
Definition: Server.cpp:118
CommandManager file.
Definition: NetworkServer.hpp:21
Definition: Box2DWorld.h:26
Server * getServer()
Definition: Server.hpp:50
Definition: PlayersOnline.hpp:26
Definition: InputThread.hpp:19
Player * getPlayer()
Definition: Server.hpp:52
ITemperatureWorldChunkableObservable< ITemperatureWorldChunkableGeneratable< ITemperatureWorldChunkableMutable< ITemperatureWorldChunkable< ITemperatureWorld > > > > TempWorld
Definition: Server.hpp:30
Networking server header file.
PlayersOnline * getPlayers() const
Definition: Server.hpp:60
Server()
Definition: Server.cpp:95
Definition: ICommandSender.hpp:12
std::shared_ptr< TempWorld > getTemperatureWorld() const
Definition: Server.hpp:64
~Server()
Definition: Server.cpp:128
bool isRunning() const
Definition: Server.hpp:58
Player class. XP, Life points and other.
Definition: Player.hpp:19
virtual Box2DWorld * getWorld()
Definition: Server.hpp:62