EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
APIServerManager.cpp
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: Aknor Jaden
24 */
25 
26 #include "eve-server.h"
27 
28 #include "EntityList.h"
30 
32 : APIServiceManager(services)
33 {
34 }
35 
36 std::tr1::shared_ptr<std::string> APIServerManager::ProcessCall(const APICommandCall * pAPICommandCall)
37 {
38  sLog.Debug("APIServerManager::ProcessCall()", "EVEmu API - Server Service Manager");
39 
40  if( pAPICommandCall->find( "servicehandler" ) == pAPICommandCall->end() )
41  {
42  sLog.Error( "APIServerManager::ProcessCall()", "Cannot find 'servicehandler' specifier in pAPICommandCall packet" );
43  return std::tr1::shared_ptr<std::string>(new std::string(""));
44  }
45 
46  if( pAPICommandCall->find( "servicehandler" )->second == "ServerStatus.xml.aspx" )
47  return _ServerStatus(pAPICommandCall);
48  //else if( pAPICommandCall->find( "servicehandler" )->second == "TODO.xml.aspx" )
49  // return _TODO(pAPICommandCall);
50  else
51  {
52  sLog.Error("APIServerManager::ProcessCall()", "EVEmu API - Server Service Manager - ERROR: Cannot resolve '%s' as a valid service query for Server Service Manager",
53  pAPICommandCall->find("servicehandler")->second.c_str() );
54  return std::tr1::shared_ptr<std::string>(new std::string(""));
55  }
56 }
57 
58 std::tr1::shared_ptr<std::string> APIServerManager::_ServerStatus(const APICommandCall * pAPICommandCall)
59 {
60  uint32 playersOnline = services().entity_list.GetClientCount();
61  std::string playersOnlineStr( itoa( playersOnline ) );
62 
64  {
65  _BuildXMLTag( "result" );
66  {
67  _BuildSingleXMLTag( "serverOpen", "True" );
68  _BuildSingleXMLTag( "onlinePlayers", playersOnlineStr );
69  }
70  _CloseXMLTag(); // close tag "result"
71  }
73 
74  return _GetXMLDocumentString();
75 }
std::tr1::shared_ptr< std::string > _GetXMLDocumentString()
void _BuildSingleXMLTag(std::string name, std::string param)
std::map< std::string, std::string > APICommandCall
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
APIServerManager(const PyServiceMgr &services)
Generic Base Class used to derive classes for specific service handlers (character, corporation, etc)
std::tr1::shared_ptr< std::string > ProcessCall(const APICommandCall *pAPICommandCall)
unsigned __int32 uint32
Definition: eve-compat.h:50
void _BuildXMLTag(std::string name)
PyServiceMgr & services()
void _CloseXMLHeader(uint32 cacheStyle)
const char * itoa(int64 num)
Convers num to string.
std::tr1::shared_ptr< std::string > _ServerStatus(const APICommandCall *pAPICommandCall)