EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ImageServer.h
Go to the documentation of this file.
1 /*
2  ------------------------------------------------------------------------------------
3  LICENSE:
4  ------------------------------------------------------------------------------------
5  This file is part of EVEmu: EVE Online Server Emulator
6  Copyright 2006 - 2021 The EVEmu Team
7  For the latest information visit https://evemu.dev
8  ------------------------------------------------------------------------------------
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU Lesser General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13 
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public License along with
19  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20  Place - Suite 330, Boston, MA 02111-1307, USA, or go to
21  http://www.gnu.org/copyleft/lesser.txt.
22  ------------------------------------------------------------------------------------
23  Author: caytchen
24 */
25 
26 #ifndef __IMAGESERVER__H__INCL__
27 #define __IMAGESERVER__H__INCL__
28 
29 #include <memory>
30 
31 #include "eve-common.h"
32 #include "utils/Singleton.h"
33 #include "EVEServerConfig.h"
34 
36 
48 class ImageServer : public Singleton<ImageServer>
49 {
50 public:
51  ImageServer();
52  void Run();
53  void Stop();
54 
55  std::string& url();
56 
57  void ReportNewImage(uint32 accountID, std::shared_ptr<std::vector<char> > imageData);
58  void ReportNewCharacter(uint32 creatorAccountID, uint32 characterID);
59 
60  std::string GetFilePath(std::string& category, uint32 id, uint32 size);
61  std::shared_ptr<std::vector<char> > GetImage(std::string& category, uint32 id, uint32 size);
62 
63  static const char *const Categories[];
64  static const uint32 CategoryCount;
65 
66  // used when the ImageServer can't find the image requested
67  // this way we don't have to transfer over all the static NPC images
68  static const char *const FallbackURL;
69 
70 private:
71  void RunInternal();
72  bool ValidateCategory(std::string& category);
73  bool ValidateSize(std::string& category, uint32 size);
74 
75  std::unordered_map<uint32 /*accountID*/, std::shared_ptr<std::vector<char> > /*imageData*/> _limboImages;
76  std::shared_ptr<boost::asio::detail::thread> _ioThread;
77  std::shared_ptr<boost::asio::io_context> _io;
78  std::shared_ptr<ImageServerListener> _listener;
79  std::string _url;
80  std::string _basePath;
81  boost::asio::detail::mutex _limboLock;
82 
83  class Lock
84  {
85  public:
86  Lock(boost::asio::detail::mutex& mutex);
87  ~Lock();
88  private:
89  boost::asio::detail::mutex& _mutex;
90  };
91 };
92 
93 #define sImageServer \
94  ( ImageServer::get() )
95 
96 #endif // __IMAGESERVER__H__INCL__
static const char *const Categories[]
Definition: ImageServer.h:63
static const char *const FallbackURL
Definition: ImageServer.h:68
boost::asio::detail::mutex & _mutex
Definition: ImageServer.h:89
void ReportNewCharacter(uint32 creatorAccountID, uint32 characterID)
Definition: ImageServer.cpp:77
Handles distribution of character and related game images.
Definition: ImageServer.h:48
void ReportNewImage(uint32 accountID, std::shared_ptr< std::vector< char > > imageData)
Definition: ImageServer.cpp:65
std::shared_ptr< std::vector< char > > GetImage(std::string &category, uint32 id, uint32 size)
std::string & url()
boost::asio::detail::mutex _limboLock
Definition: ImageServer.h:81
void RunInternal()
bool ValidateSize(std::string &category, uint32 size)
std::shared_ptr< ImageServerListener > _listener
Definition: ImageServer.h:78
Handles listening for new clients.
std::string _url
Definition: ImageServer.h:79
static const uint32 CategoryCount
Definition: ImageServer.h:64
Lock(boost::asio::detail::mutex &mutex)
unsigned __int32 uint32
Definition: eve-compat.h:50
std::shared_ptr< boost::asio::detail::thread > _ioThread
Definition: ImageServer.h:76
std::shared_ptr< boost::asio::io_context > _io
Definition: ImageServer.h:77
std::string _basePath
Definition: ImageServer.h:80
std::string GetFilePath(std::string &category, uint32 id, uint32 size)
Template used for singleton classes.
Definition: Singleton.h:43
bool ValidateCategory(std::string &category)
std::unordered_map< uint32, std::shared_ptr< std::vector< char > > > _limboImages
Definition: ImageServer.h:75