TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
RealmList.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
3  * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; either version 2 of the License, or (at your
8  * option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef _REALMLIST_H
20 #define _REALMLIST_H
21 
22 #include "Common.h"
23 #include "Realm/Realm.h"
24 #include <boost/asio/ip/address.hpp>
25 #include <boost/asio/ip/tcp.hpp>
26 #include <boost/asio/io_service.hpp>
27 #include <boost/asio/deadline_timer.hpp>
28 
29 using namespace boost::asio;
30 
32 {
38 };
39 
40 namespace bgs
41 {
42  namespace protocol
43  {
44  namespace game_utilities
45  {
46  namespace v1
47  {
48  class ClientResponse;
49  class GetAllValuesForAttributeResponse;
50  }
51  }
52  }
53 }
54 
55 namespace JSON
56 {
57  namespace RealmList
58  {
59  class RealmListUpdates;
60  }
61 }
62 
65 {
66 public:
67  typedef std::map<Battlenet::RealmHandle, Realm> RealmMap;
68 
69  static RealmList* Instance();
70 
71  ~RealmList();
72 
73  void Initialize(boost::asio::io_service& ioService, uint32 updateInterval);
74  void Close();
75 
76  RealmMap const& GetRealms() const { return _realms; }
77  Realm const* GetRealm(Battlenet::RealmHandle const& id) const;
78 
79  RealmBuildInfo const* GetBuildInfo(uint32 build) const;
80  std::unordered_set<std::string> const& GetSubRegions() const { return _subRegions; }
81  void WriteSubRegions(bgs::protocol::game_utilities::v1::GetAllValuesForAttributeResponse* response) const;
82  std::vector<uint8> GetRealmEntryJSON(Battlenet::RealmHandle const& id, uint32 build) const;
83  std::vector<uint8> GetRealmList(uint32 build, std::string const& subRegion) const;
84  uint32 JoinRealm(uint32 realmAddress, uint32 build, boost::asio::ip::address const& clientAddress, std::array<uint8, 32> const& clientSecret,
85  LocaleConstant locale, std::string const& os, std::string accountName, bgs::protocol::game_utilities::v1::ClientResponse* response) const;
86 
87 private:
88  RealmList();
89 
90  void UpdateRealms(boost::system::error_code const& error);
91  void UpdateRealm(Battlenet::RealmHandle const& id, uint32 build, const std::string& name, ip::address const& address, ip::address const& localAddr,
92  ip::address const& localSubmask, uint16 port, uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, float population);
93 
94  RealmMap _realms;
95  std::unordered_set<std::string> _subRegions;
97  boost::asio::deadline_timer* _updateTimer;
98  boost::asio::ip::tcp::resolver* _resolver;
99 };
100 
101 #define sRealmList RealmList::Instance()
102 #endif
boost::asio::ip::tcp::resolver * _resolver
Definition: RealmList.h:98
uint32 BugfixVersion
Definition: RealmList.h:36
Definition: Session.h:36
Definition: Realm.h:84
uint32 MinorVersion
Definition: RealmList.h:35
uint32 Build
Definition: RealmList.h:33
std::unordered_set< std::string > const & GetSubRegions() const
Definition: RealmList.h:80
LocaleConstant
Definition: Common.h:115
Storage object for the list of realms on the server.
Definition: RealmList.h:64
RealmMap const & GetRealms() const
Definition: RealmList.h:76
uint32_t uint32
Definition: Define.h:150
static void Initialize(PCASC_SALSA20 pState, LPBYTE pbKey, DWORD cbKeyLength, LPBYTE pbVector)
Definition: CascDecrypt.cpp:81
AccountTypes
Definition: Common.h:106
#define TC_SHARED_API
Definition: Define.h:128
uint16_t uint16
Definition: Define.h:151
Definition: game_utilities_service.pb.h:204
boost::asio::deadline_timer * _updateTimer
Definition: RealmList.h:97
RealmFlags
Definition: Realm.h:27
Definition: Realm.h:44
uint8_t uint8
Definition: Define.h:152
RealmMap _realms
Definition: RealmList.h:94
uint32 HotfixVersion
Definition: RealmList.h:37
Definition: RealmList.h:31
std::unordered_set< std::string > _subRegions
Definition: RealmList.h:95
uint32 _updateInterval
Definition: RealmList.h:96
Definition: RealmList.pb.h:30
uint32 MajorVersion
Definition: RealmList.h:34
std::map< Battlenet::RealmHandle, Realm > RealmMap
Definition: RealmList.h:67