duncan
Mom and Dad were wrong!
|
00001 #ifndef SERVER_SERVER_H_ 00002 #define SERVER_SERVER_H_ 00003 00004 #include <cstring> 00005 #include <string> 00006 #include <iostream> 00007 #include <sstream> 00008 #include <tr1/memory> 00009 #include <vector> 00010 #include <map> 00011 #include "../network/network.h" 00012 #include "../network/connection.h" 00013 #include "../network/packetlistener.h" 00014 #include "world.h" 00015 #include "../timer/timer.h" 00016 00017 namespace server { 00018 00029 class Server : public net::PacketListener { 00030 private: 00031 static const size_t kMaxWorlds=10; 00032 static const double kSecondsPerUpdate; 00033 static const size_t kSecondsPerInfoPrint=1; 00034 00035 std::string curl_url_; 00036 00037 timer::Timer timer_, second_timer_; 00038 00039 unsigned int frame_count_; 00040 00041 bool running_; 00042 size_t windex_; 00043 std::vector<std::tr1::shared_ptr<World> > worlds_; 00044 std::vector<Player> players_; 00045 std::map<const std::string,size_t> world_ids_; 00046 00047 net::Connection con_; 00048 00049 void sendcanchange(net::index_t,size_t); 00050 public: 00051 Server(); 00052 00053 void on_packet(net::data_t* buf, size_t size, net::index_t peer); 00054 void on_connect(net::index_t peer); 00055 void on_disconnect(net::index_t peer); 00056 00057 void message(const std::string& str); 00058 00059 bool update(); 00060 }; 00061 00062 } // namespace 00063 00064 #endif