EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
PyService Class Reference

#include "PyService.h"

Inherits PyCallable.

Inherited by AccountService, AgentMgrService, AggressionMgrService, AlertService, AllianceRegistry, AuthService, BeyonceService, BillMgr, BookmarkService, BrowserLockdownService, BulkMgrService, CalendarMgrService, CalendarProxy, CertificateMgrService, CharFittingMgr, CharMgrService, CharUnboundMgrService, ClientStatLogger, ClientStatsMgr, ConfigService, ContractMgr, ContractProxy, CorpBookmarkMgr, CorpFittingMgr, CorpMgrService, CorporationService, CorpRegistryService, CorpStationMgr, DevToolsProviderService, DogmaIMService, DogmaService, DungeonExplorationMgrService, DungeonService, encounterSpawnServer, EntityService, EpicArcService, FactionWarMgrService, FactoryService, FleetManager, FleetObject, FleetProxy, HoloscreenMgrService, IndexManager, InfoGatheringMgr, InsuranceService, InvBrokerService, JumpCloneService, KeeperService, LanguageService, LocalizationServerService, LookupService, LPService, LPStore, LSCService, MailingListMgrService, MailMgrService, MapService, MarketProxyService, MissionMgrService, MovementService, NetService, netStateServer, NotificationMgrService, ObjCacheService, OnlineStatusService, PaperDollService, PetitionerService, PhotoUploadService, PlanetMgrService, PlanetORB, PosMgr, RamProxyService, RepairService, ReprocessingService, ScanMgrService, ScenarioService, Search, ShipService, SkillMgrService, SlashService, SovereigntyMgrService, Standing, StationService, StationSvc, TradeService, TutorialService, UserService, VoiceMgrService, VoucherService, WarRegistryService, WorldSpaceServer, WormHoleSvc, and zActionServer.

Collaboration diagram for PyService:

Public Member Functions

 PyService (PyServiceMgr *mgr, const char *serviceName)
 
virtual ~PyService ()
 
virtual PyResult Call (const std::string &method, PyCallArgs &args)
 
const char * GetName () const
 
- Public Member Functions inherited from PyCallable
 PyCallable ()
 
virtual ~PyCallable ()
 

Protected Types

enum  CacheCheckTime {
  check_Always = 0, check_Never, check_in_year, check_in_6_months,
  check_in_3_months, check_in_1_month, check_in_1_week, check_in_1_day,
  check_in_12_hours, check_in_6_hours, check_in_3_hours, check_in_2_hours,
  check_in_1_hour, check_in_30_minutes, check_in_15_minutes, check_in_5_minutes,
  check_in_1_minute, check_in_30_seconds, check_in_15_seconds, check_in_5_seconds,
  check_in_1_second, _checkCount
}
 

Protected Member Functions

PyObject_BuildCachedReturn (PySubStream **result, const char *sessionInfo, CacheCheckTime check)
 
virtual PyBoundObjectCreateBoundObject (Client *pClient, const PyRep *bind_args)
 
virtual PyResult Handle_MachoResolveObject (PyCallArgs &call)
 
virtual PyResult Handle_MachoBindObject (PyCallArgs &call)
 
- Protected Member Functions inherited from PyCallable
void _SetCallDispatcher (CallDispatcher *d)
 

Protected Attributes

PyServiceMgr *const m_manager
 

Static Protected Attributes

static const char *const s_checkTimeStrings [_checkCount]
 

Private Attributes

const char * m_name
 

Detailed Description

Definition at line 46 of file PyService.h.

Member Enumeration Documentation

enum PyService::CacheCheckTime
protected
Enumerator
check_Always 
check_Never 
check_in_year 
check_in_6_months 
check_in_3_months 
check_in_1_month 
check_in_1_week 
check_in_1_day 
check_in_12_hours 
check_in_6_hours 
check_in_3_hours 
check_in_2_hours 
check_in_1_hour 
check_in_30_minutes 
check_in_15_minutes 
check_in_5_minutes 
check_in_1_minute 
check_in_30_seconds 
check_in_15_seconds 
check_in_5_seconds 
check_in_1_second 
_checkCount 

Definition at line 57 of file PyService.h.

57  { //enum to make sure the caller uses legit values.
58  check_Always = 0,
CacheCheckTime
Definition: PyService.h:57

Constructor & Destructor Documentation

PyService::PyService ( PyServiceMgr mgr,
const char *  serviceName 
)

Definition at line 32 of file PyService.cpp.

33 : m_manager(mgr),
34  m_name(serviceName)
35 {
36 }
const char * m_name
Definition: PyService.h:94
PyServiceMgr *const m_manager
Definition: PyService.h:91
PyService::~PyService ( )
virtual

Definition at line 38 of file PyService.cpp.

39 {
40 }

Member Function Documentation

PyObject * PyService::_BuildCachedReturn ( PySubStream **  result,
const char *  sessionInfo,
CacheCheckTime  check 
)
protected

Definition at line 142 of file PyService.cpp.

References _log, PyBuffer::content(), crc_hqx(), PySubStream::data(), PySubStream::EncodeData(), GetName(), PyDecRef, s_checkTimeStrings, Buffer::size(), and Win32TimeNow().

143 {
144  objectCaching_CachedMethodCallResult cached;
145 
146  PySubStream* result = *in_result;
147  *in_result = nullptr; //consume it.
148 
149  //we need to checksum the marshaled data...
150  result->EncodeData();
151  if (!result->data()) {
152  _log( SERVICE__ERROR, "%s: Failed to build cached return", GetName() );
153 
154  PyDecRef( result );
155  return nullptr;
156  }
157 
158  cached.call_return = result; //this entire result is going to get cloned in the Encode(), and then destroyed when we return... what a waste...
159  cached.sessionInfo = sessionInfo;
160  cached.clientWhen = s_checkTimeStrings[ check ];
161 
162  cached.timeStamp = Win32TimeNow();
163  //we can use whatever checksum we want here, as the client just remembers it and sends it back to us.
164  cached.version = crc_hqx( &result->data()->content()[0], result->data()->content().size(), 0 );
165 
166  return cached.Encode();
167 }
#define _log(type, fmt,...)
Definition: logsys.h:124
const Buffer & content() const
Get the const PyBuffer content.
Definition: PyRep.h:407
PyBuffer * data() const
Definition: PyRep.h:1047
const char * GetName() const
Definition: PyService.h:54
int64 Win32TimeNow()
Definition: utils_time.cpp:70
uint16 crc_hqx(const uint8 *data, size_t len, uint16 crc)
Definition: misc.cpp:67
#define PyDecRef(op)
Definition: PyRep.h:57
static const char *const s_checkTimeStrings[_checkCount]
Definition: PyService.h:81
size_type size() const
Definition: Buffer.h:610
void EncodeData() const
Definition: PyRep.cpp:1109

Here is the call graph for this function:

PyResult PyService::Call ( const std::string &  method,
PyCallArgs args 
)
virtual

Reimplemented from PyCallable.

Definition at line 43 of file PyService.cpp.

References _log, PyCallable::Call(), PyCallArgs::Dump(), GetName(), Handle_MachoBindObject(), and Handle_MachoResolveObject().

43  {
44  if (method == "MachoResolveObject"){
45  _log(SERVICE__CALLS, "%s::MachoResolveObject()", GetName());
46  return Handle_MachoResolveObject(args);
47  } else if (method == "MachoBindObject") {
48  _log(SERVICE__CALLS, "%s::MachoBindObject()", GetName());
49  return Handle_MachoBindObject(args);
50  } else {
51  _log(SERVICE__CALLS, "%s::%s()", GetName(), method.c_str());
52  args.Dump(SERVICE__CALL_TRACE);
53  return PyCallable::Call(method, args);
54  }
55 }
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * GetName() const
Definition: PyService.h:54
virtual PyResult Handle_MachoResolveObject(PyCallArgs &call)
Definition: PyService.cpp:63
virtual PyResult Handle_MachoBindObject(PyCallArgs &call)
Definition: PyService.cpp:70
void Dump(LogType type) const
Definition: PyCallable.cpp:81
virtual PyResult Call(const std::string &method, PyCallArgs &args)
Definition: PyCallable.cpp:39

Here is the call graph for this function:

PyBoundObject * PyService::CreateBoundObject ( Client pClient,
const PyRep bind_args 
)
protectedvirtual

Reimplemented in CharMgrService, CorpRegistryService, TradeService, AgentMgrService, CorpStationMgr, KeeperService, AllianceRegistry, ShipService, DogmaIMService, InsuranceService, JumpCloneService, InvBrokerService, ReprocessingService, SkillMgrService, PlanetMgrService, RepairService, AggressionMgrService, PlanetORB, WarRegistryService, PosMgr, FleetObject, and EntityService.

Definition at line 169 of file PyService.cpp.

References _log, and EvE::traceStack().

Referenced by Handle_MachoBindObject().

170 {
171  _log( SERVICE__ERROR, "Called default CreateBoundObject()");
172  EvE::traceStack();
173  return nullptr;
174 }
#define _log(type, fmt,...)
Definition: logsys.h:124
void traceStack(void)
Definition: misc.cpp:169

Here is the call graph for this function:

Here is the caller graph for this function:

PyResult PyService::Handle_MachoBindObject ( PyCallArgs call)
protectedvirtual

Definition at line 70 of file PyService.cpp.

References _log, args, PyServiceMgr::BindObject(), PyBoundObject::Call(), PyCallArgs::client, codelog, CreateBoundObject(), GetName(), m_manager, PyStatic, PyTuple::SetItem(), PyResult::ssResult, and PyCallArgs::tuple.

Referenced by Call().

71 {
72  CallMachoBindObject args;
73  if (!args.Decode(&call.tuple)) {
74  codelog( SERVICE__ERROR, "%s Service: Failed to decode arguments", GetName() );
75  return nullptr;
76  }
77 
78  _log( SERVICE__MESSAGE, "%s Service: Processing MachoBindObject", GetName() );
79 
80  //first we need to get our implementation to actually create the object they are trying to bind to.
81  PyBoundObject* obj = CreateBoundObject(call.client, args.bindParams);
82  if (obj == nullptr) {
83  _log( SERVICE__ERROR, "%s Service: Unable to create bound object:", GetName());
84  args.bindParams->Dump(SERVICE__ERROR, " ");
85 
86  return nullptr;
87  }
88 
89  //now we register
90  PyTuple* rsp = new PyTuple(2);
91  PyDict* oid = new PyDict();
92  rsp->SetItem(0, m_manager->BindObject(call.client, obj, nullptr, oid));
93 
94  if (args.call->IsNone()) {
95  //no call was specified...
96  rsp->SetItem(1, PyStatic.NewNone());
97  } else {
98  CallMachoBindObject_call boundcall;
99  if (!boundcall.Decode(&args.call)) {
100  codelog(SERVICE__ERROR, "%s Service: Failed to decode boundcall arguments", GetName());
101  return nullptr;
102  }
103 
104  _log(SERVICE__MESSAGE, "%s Service: MachoBindObject also contains call to %s", GetName(), boundcall.method_name.c_str());
105 
106  PyCallArgs sub_args(call.client, boundcall.arguments, boundcall.dict_arguments);
107 
108  //do the call:
109  PyResult result = obj->Call(boundcall.method_name, sub_args);
110 
111  rsp->SetItem(1, result.ssResult);
112  }
113 
114  return PyResult(rsp, oid);
115 }
#define _log(type, fmt,...)
Definition: logsys.h:124
Python's dictionary.
Definition: PyRep.h:719
virtual PyResult Call(const std::string &method, PyCallArgs &args)
Python tuple.
Definition: PyRep.h:567
const char * GetName() const
Definition: PyService.h:54
* args
PyRep * ssResult
Definition: PyCallable.h:65
#define codelog(type, fmt,...)
Definition: logsys.h:128
void SetItem(size_t index, PyRep *object)
Stores Python object.
Definition: PyRep.h:610
PyServiceMgr *const m_manager
Definition: PyService.h:91
#define PyStatic
Definition: PyRep.h:1209
Client *const client
Definition: PyCallable.h:49
virtual PyBoundObject * CreateBoundObject(Client *pClient, const PyRep *bind_args)
Definition: PyService.cpp:169
PySubStruct * BindObject(Client *pClient, PyBoundObject *pObj, PyDict *dict=nullptr, PyDict *oid=nullptr)
PyTuple * tuple
Definition: PyCallable.h:50

Here is the call graph for this function:

Here is the caller graph for this function:

PyResult PyService::Handle_MachoResolveObject ( PyCallArgs call)
protectedvirtual

Definition at line 63 of file PyService.cpp.

References _log, GetName(), PyServiceMgr::GetNodeID(), and m_manager.

Referenced by Call().

63  {
64  //returns nodeID
65  _log(SERVICE__MESSAGE, "%s Service: MachoResolveObject requested, returning %u", GetName(), m_manager->GetNodeID());
66  return new PyInt(m_manager->GetNodeID());
67 }
#define _log(type, fmt,...)
Definition: logsys.h:124
uint32 GetNodeID() const
Definition: PyServiceMgr.h:67
const char * GetName() const
Definition: PyService.h:54
Python integer.
Definition: PyRep.h:231
PyServiceMgr *const m_manager
Definition: PyService.h:91

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

const char* PyService::m_name
private

Definition at line 94 of file PyService.h.

Referenced by GetName().

const char *const PyService::s_checkTimeStrings
staticprotected
Initial value:
= {
"always",
"never",
"year",
"6 months",
"3 months",
"month",
"week",
"day",
"12 hours",
"6 hours",
"3 hours",
"2 hours",
"1 hour",
"30 minutes",
"15 minutes",
"5 minutes",
"1 minute",
"30 seconds",
"15 seconds",
"5 seconds",
"1 second"
}

Definition at line 81 of file PyService.h.

Referenced by _BuildCachedReturn().


The documentation for this class was generated from the following files: