00001
00003
00005
00006 #ifndef WELCOME_SERVICE_ITF
00007 #define WELCOME_SERVICE_ITF
00008 #include "nel/misc/types_nl.h"
00009 #ifdef NL_COMP_VC8
00010 #include <memory>
00011 #endif
00012 #include "nel/misc/hierarchical_timer.h"
00013 #include "nel/misc/string_conversion.h"
00014 #include "nel/net/message.h"
00015 #include "nel/net/module.h"
00016 #include "nel/net/module_builder_parts.h"
00017 #include "nel/net/module_message.h"
00018 #include "nel/net/module_gateway.h"
00019
00020 #include "nel/net/login_cookie.h"
00021
00022 namespace WS
00023 {
00024
00025
00026
00027 struct TUserRole
00028 {
00029 enum TValues
00030 {
00031 ur_player,
00032 ur_editor,
00033 ur_animator,
00035 last_enum_item = ur_animator,
00037 end_of_enum,
00038
00039 invalid_val,
00040
00042 nb_enum_items = 3
00043 };
00044
00046 const std::map<TValues, uint32> &getIndexTable() const
00047 {
00048 static std::map<TValues, uint32> indexTable;
00049 static bool init = false;
00050 if (!init)
00051 {
00052
00053 indexTable.insert(std::make_pair(ur_player, 0));
00054 indexTable.insert(std::make_pair(ur_editor, 1));
00055 indexTable.insert(std::make_pair(ur_animator, 2));
00056
00057 init = true;
00058 }
00059
00060 return indexTable;
00061 }
00062
00063
00064 static const NLMISC::CStringConversion<TValues> &getConversionTable()
00065 {
00066 NL_BEGIN_STRING_CONVERSION_TABLE(TValues)
00067 NL_STRING_CONVERSION_TABLE_ENTRY(ur_player)
00068 NL_STRING_CONVERSION_TABLE_ENTRY(ur_editor)
00069 NL_STRING_CONVERSION_TABLE_ENTRY(ur_animator)
00070 NL_STRING_CONVERSION_TABLE_ENTRY(invalid_val)
00071 };
00072 static NLMISC::CStringConversion<TValues>
00073 conversionTable(TValues_nl_string_conversion_table, sizeof(TValues_nl_string_conversion_table)
00074 / sizeof(TValues_nl_string_conversion_table[0]), invalid_val);
00075
00076 return conversionTable;
00077 }
00078
00079 TValues _Value;
00080
00081 public:
00082 TUserRole()
00083 : _Value(invalid_val)
00084 {
00085 }
00086 TUserRole(TValues value)
00087 : _Value(value)
00088 {
00089 }
00090
00091 TUserRole(const std::string &str)
00092 {
00093 _Value = getConversionTable().fromString(str);
00094 }
00095
00096 void serial(NLMISC::IStream &s)
00097 {
00098 s.serialEnum(_Value);
00099 }
00100
00101 bool operator == (const TUserRole &other) const
00102 {
00103 return _Value == other._Value;
00104 }
00105 bool operator != (const TUserRole &other) const
00106 {
00107 return ! (_Value == other._Value);
00108 }
00109 bool operator < (const TUserRole &other) const
00110 {
00111 return _Value < other._Value;
00112 }
00113
00114 bool operator <= (const TUserRole &other) const
00115 {
00116 return _Value <= other._Value;
00117 }
00118
00119 bool operator > (const TUserRole &other) const
00120 {
00121 return !(_Value <= other._Value);
00122 }
00123 bool operator >= (const TUserRole &other) const
00124 {
00125 return !(_Value < other._Value);
00126 }
00127
00128 const std::string &toString() const
00129 {
00130 return getConversionTable().toString(_Value);
00131 }
00132 static const std::string &toString(TValues value)
00133 {
00134 return getConversionTable().toString(value);
00135 }
00136
00137 TValues getValue() const
00138 {
00139 return _Value;
00140 }
00141
00142
00143 bool isValid()
00144 {
00145 if (_Value == invalid_val)
00146 return false;
00147
00148
00149 return getConversionTable().isValid(_Value);
00150 }
00151
00152
00153 uint32 asIndex()
00154 {
00155 std::map<TValues, uint32>::const_iterator it(getIndexTable().find(_Value));
00156 nlassert(it != getIndexTable().end());
00157 return it->second;
00158 }
00159
00160 };
00161
00163
00165 class CWelcomeServiceSkel
00166 {
00167 public:
00169 typedef NLNET::CInterceptorForwarder < CWelcomeServiceSkel> TInterceptor;
00170 protected:
00171 CWelcomeServiceSkel()
00172 {
00173
00174 getMessageHandlers();
00175 }
00176 virtual ~CWelcomeServiceSkel()
00177 {
00178 }
00179
00180 void init(NLNET::IModule *module)
00181 {
00182 _Interceptor.init(this, module);
00183 }
00184
00185
00186 std::string fwdBuildModuleManifest() const { return std::string(); }
00187 void fwdOnModuleUp(NLNET::IModuleProxy * ) {}
00188 void fwdOnModuleDown(NLNET::IModuleProxy * ) {}
00189 void fwdOnModuleSecurityChange(NLNET::IModuleProxy * ) {}
00190
00191
00192 bool fwdOnProcessModuleMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message);
00193 private:
00194
00195 typedef void (CWelcomeServiceSkel::*TMessageHandler)(NLNET::IModuleProxy *sender, const NLNET::CMessage &message);
00196 typedef std::map<std::string, TMessageHandler> TMessageHandlerMap;
00197
00198 const TMessageHandlerMap &getMessageHandlers() const;
00199
00200
00201 void welcomeUser_skel(NLNET::IModuleProxy *sender, const NLNET::CMessage &__message);
00202
00203 void disconnectUser_skel(NLNET::IModuleProxy *sender, const NLNET::CMessage &__message);
00204
00205
00206 TInterceptor _Interceptor;
00207
00208
00209 friend class NLNET::CInterceptorForwarder < CWelcomeServiceSkel>;
00210 public:
00212
00214
00215
00216 virtual void welcomeUser(NLNET::IModuleProxy *sender, uint32 charId, const std::string &userName, const NLNET::CLoginCookie &cookie, const std::string &priviledge, const std::string &exPriviledge, WS::TUserRole mode, uint32 instanceId) =0;
00217
00218 virtual void disconnectUser(NLNET::IModuleProxy *sender, uint32 userId) =0;
00219
00220
00221 };
00222
00224
00226 class CWelcomeServiceProxy
00227 {
00229 NLNET::TModuleProxyPtr _ModuleProxy;
00230
00231
00232 NLNET::TModulePtr _LocalModule;
00233
00234 CWelcomeServiceSkel *_LocalModuleSkel;
00235
00236
00237 public:
00238 CWelcomeServiceProxy(NLNET::IModuleProxy *proxy)
00239 {
00240 nlassert(proxy->getModuleClassName() == "WelcomeService");
00241 _ModuleProxy = proxy;
00242
00243
00244 if (proxy->getModuleDistance() == 0)
00245 {
00246 _LocalModule = proxy->getLocalModule();
00247 nlassert(_LocalModule != NULL);
00248 CWelcomeServiceSkel::TInterceptor *interceptor = NULL;
00249 interceptor = static_cast < NLNET::CModuleBase* >(_LocalModule.getPtr())->getInterceptor(interceptor);
00250 nlassert(interceptor != NULL);
00251
00252 _LocalModuleSkel = interceptor->getParent();
00253 nlassert(_LocalModuleSkel != NULL);
00254 }
00255 else
00256 _LocalModuleSkel = 0;
00257
00258 }
00259 virtual ~CWelcomeServiceProxy()
00260 {
00261 }
00262
00263 NLNET::IModuleProxy *getModuleProxy()
00264 {
00265 return _ModuleProxy;
00266 }
00267
00268
00269 void welcomeUser(NLNET::IModule *sender, uint32 charId, const std::string &userName, const NLNET::CLoginCookie &cookie, const std::string &priviledge, const std::string &exPriviledge, WS::TUserRole mode, uint32 instanceId);
00270
00271 void disconnectUser(NLNET::IModule *sender, uint32 userId);
00272
00273
00274 static const NLNET::CMessage &buildMessageFor_welcomeUser(NLNET::CMessage &__message, uint32 charId, const std::string &userName, const NLNET::CLoginCookie &cookie, const std::string &priviledge, const std::string &exPriviledge, WS::TUserRole mode, uint32 instanceId);
00275
00276
00277 static const NLNET::CMessage &buildMessageFor_disconnectUser(NLNET::CMessage &__message, uint32 userId);
00278
00279
00280
00281
00282 };
00283
00285
00287 class CLoginServiceSkel
00288 {
00289 public:
00291 typedef NLNET::CInterceptorForwarder < CLoginServiceSkel> TInterceptor;
00292 protected:
00293 CLoginServiceSkel()
00294 {
00295
00296 getMessageHandlers();
00297 }
00298 virtual ~CLoginServiceSkel()
00299 {
00300 }
00301
00302 void init(NLNET::IModule *module)
00303 {
00304 _Interceptor.init(this, module);
00305 }
00306
00307
00308 std::string fwdBuildModuleManifest() const { return std::string(); }
00309 void fwdOnModuleUp(NLNET::IModuleProxy * ) {}
00310 void fwdOnModuleDown(NLNET::IModuleProxy * ) {}
00311 void fwdOnModuleSecurityChange(NLNET::IModuleProxy * ) {}
00312
00313
00314 bool fwdOnProcessModuleMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message);
00315 private:
00316
00317 typedef void (CLoginServiceSkel::*TMessageHandler)(NLNET::IModuleProxy *sender, const NLNET::CMessage &message);
00318 typedef std::map<std::string, TMessageHandler> TMessageHandlerMap;
00319
00320 const TMessageHandlerMap &getMessageHandlers() const;
00321
00322
00323 void pendingUserLost_skel(NLNET::IModuleProxy *sender, const NLNET::CMessage &__message);
00324
00325
00326 TInterceptor _Interceptor;
00327
00328
00329 friend class NLNET::CInterceptorForwarder < CLoginServiceSkel>;
00330 public:
00332
00334
00335
00336 virtual void pendingUserLost(NLNET::IModuleProxy *sender, const NLNET::CLoginCookie &cookie) =0;
00337
00338
00339 };
00340
00342
00344 class CLoginServiceProxy
00345 {
00347 NLNET::TModuleProxyPtr _ModuleProxy;
00348
00349
00350 NLNET::TModulePtr _LocalModule;
00351
00352 CLoginServiceSkel *_LocalModuleSkel;
00353
00354
00355 public:
00356 CLoginServiceProxy(NLNET::IModuleProxy *proxy)
00357 {
00358
00359 _ModuleProxy = proxy;
00360
00361
00362 if (proxy->getModuleDistance() == 0)
00363 {
00364 _LocalModule = proxy->getLocalModule();
00365 nlassert(_LocalModule != NULL);
00366 CLoginServiceSkel::TInterceptor *interceptor = NULL;
00367 interceptor = static_cast < NLNET::CModuleBase* >(_LocalModule.getPtr())->getInterceptor(interceptor);
00368 nlassert(interceptor != NULL);
00369
00370 _LocalModuleSkel = interceptor->getParent();
00371 nlassert(_LocalModuleSkel != NULL);
00372 }
00373 else
00374 _LocalModuleSkel = 0;
00375
00376 }
00377 virtual ~CLoginServiceProxy()
00378 {
00379 }
00380
00381 NLNET::IModuleProxy *getModuleProxy()
00382 {
00383 return _ModuleProxy;
00384 }
00385
00386
00387 void pendingUserLost(NLNET::IModule *sender, const NLNET::CLoginCookie &cookie);
00388
00389
00390 static const NLNET::CMessage &buildMessageFor_pendingUserLost(NLNET::CMessage &__message, const NLNET::CLoginCookie &cookie);
00391
00392
00393
00394
00395 };
00396
00398
00400 class CWelcomeServiceClientSkel
00401 {
00402 public:
00404 typedef NLNET::CInterceptorForwarder < CWelcomeServiceClientSkel> TInterceptor;
00405 protected:
00406 CWelcomeServiceClientSkel()
00407 {
00408
00409 getMessageHandlers();
00410 }
00411 virtual ~CWelcomeServiceClientSkel()
00412 {
00413 }
00414
00415 void init(NLNET::IModule *module)
00416 {
00417 _Interceptor.init(this, module);
00418 }
00419
00420
00421 std::string fwdBuildModuleManifest() const { return std::string(); }
00422 void fwdOnModuleUp(NLNET::IModuleProxy * ) {}
00423 void fwdOnModuleDown(NLNET::IModuleProxy * ) {}
00424 void fwdOnModuleSecurityChange(NLNET::IModuleProxy * ) {}
00425
00426
00427 bool fwdOnProcessModuleMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message);
00428 private:
00429
00430 typedef void (CWelcomeServiceClientSkel::*TMessageHandler)(NLNET::IModuleProxy *sender, const NLNET::CMessage &message);
00431 typedef std::map<std::string, TMessageHandler> TMessageHandlerMap;
00432
00433 const TMessageHandlerMap &getMessageHandlers() const;
00434
00435
00436 void registerWS_skel(NLNET::IModuleProxy *sender, const NLNET::CMessage &__message);
00437
00438 void reportWSOpenState_skel(NLNET::IModuleProxy *sender, const NLNET::CMessage &__message);
00439
00440 void welcomeUserResult_skel(NLNET::IModuleProxy *sender, const NLNET::CMessage &__message);
00441
00442 void updateConnectedPlayerCount_skel(NLNET::IModuleProxy *sender, const NLNET::CMessage &__message);
00443
00444
00445 TInterceptor _Interceptor;
00446
00447
00448 friend class NLNET::CInterceptorForwarder < CWelcomeServiceClientSkel>;
00449 public:
00451
00453
00454
00455
00456 virtual void registerWS(NLNET::IModuleProxy *sender, uint32 shardId, uint32 fixedSessionId, bool isOnline) =0;
00457
00458 virtual void reportWSOpenState(NLNET::IModuleProxy *sender, bool isOnline) =0;
00459
00460 virtual void welcomeUserResult(NLNET::IModuleProxy *sender, uint32 userId, bool ok, const std::string &shardAddr, const std::string &errorMsg) =0;
00461
00462 virtual void updateConnectedPlayerCount(NLNET::IModuleProxy *sender, uint32 nbOnlinePlayers, uint32 nbPendingPlayers) =0;
00463
00464
00465 };
00466
00468
00470 class CWelcomeServiceClientProxy
00471 {
00473 NLNET::TModuleProxyPtr _ModuleProxy;
00474
00475
00476 NLNET::TModulePtr _LocalModule;
00477
00478 CWelcomeServiceClientSkel *_LocalModuleSkel;
00479
00480
00481 public:
00482 CWelcomeServiceClientProxy(NLNET::IModuleProxy *proxy)
00483 {
00484
00485 _ModuleProxy = proxy;
00486
00487
00488 if (proxy->getModuleDistance() == 0)
00489 {
00490 _LocalModule = proxy->getLocalModule();
00491 nlassert(_LocalModule != NULL);
00492 CWelcomeServiceClientSkel::TInterceptor *interceptor = NULL;
00493 interceptor = static_cast < NLNET::CModuleBase* >(_LocalModule.getPtr())->getInterceptor(interceptor);
00494 nlassert(interceptor != NULL);
00495
00496 _LocalModuleSkel = interceptor->getParent();
00497 nlassert(_LocalModuleSkel != NULL);
00498 }
00499 else
00500 _LocalModuleSkel = 0;
00501
00502 }
00503 virtual ~CWelcomeServiceClientProxy()
00504 {
00505 }
00506
00507 NLNET::IModuleProxy *getModuleProxy()
00508 {
00509 return _ModuleProxy;
00510 }
00511
00512
00513
00514 void registerWS(NLNET::IModule *sender, uint32 shardId, uint32 fixedSessionId, bool isOnline);
00515
00516 void reportWSOpenState(NLNET::IModule *sender, bool isOnline);
00517
00518 void welcomeUserResult(NLNET::IModule *sender, uint32 userId, bool ok, const std::string &shardAddr, const std::string &errorMsg);
00519
00520 void updateConnectedPlayerCount(NLNET::IModule *sender, uint32 nbOnlinePlayers, uint32 nbPendingPlayers);
00521
00522
00523 static const NLNET::CMessage &buildMessageFor_registerWS(NLNET::CMessage &__message, uint32 shardId, uint32 fixedSessionId, bool isOnline);
00524
00525
00526 static const NLNET::CMessage &buildMessageFor_reportWSOpenState(NLNET::CMessage &__message, bool isOnline);
00527
00528
00529 static const NLNET::CMessage &buildMessageFor_welcomeUserResult(NLNET::CMessage &__message, uint32 userId, bool ok, const std::string &shardAddr, const std::string &errorMsg);
00530
00531
00532 static const NLNET::CMessage &buildMessageFor_updateConnectedPlayerCount(NLNET::CMessage &__message, uint32 nbOnlinePlayers, uint32 nbPendingPlayers);
00533
00534
00535
00536
00537 };
00538
00539 }
00540
00541 #endif