@@ -49,6 +49,7 @@ Baseappmgr::Baseappmgr(Mercury::EventDispatcher& dispatcher,
49
49
forward_baseapp_messagebuffer_ (ninterface, BASEAPP_TYPE),
50
50
bestBaseappID_(0 ),
51
51
baseapps_(),
52
+ pending_logins_(),
52
53
baseappsInitProgress_(0 .f)
53
54
{
54
55
}
@@ -291,8 +292,17 @@ void Baseappmgr::registerPendingAccountToBaseapp(Mercury::Channel* pChannel,
291
292
std::string& password, DBID entityDBID, uint32 flags, uint64 deadline,
292
293
COMPONENT_TYPE componentType)
293
294
{
295
+ Components::ComponentInfos* cinfos = Components::getSingleton ().findComponent (pChannel);
296
+ if (cinfos == NULL || cinfos->pChannel == NULL )
297
+ {
298
+ ERROR_MSG (" Baseappmgr::registerPendingAccountToBaseapp: not found loginapp!\n " );
299
+ return ;
300
+ }
301
+
302
+ pending_logins_[loginName] = cinfos->cid ;
303
+
294
304
ENTITY_ID eid = 0 ;
295
- Components::ComponentInfos* cinfos =
305
+ cinfos =
296
306
Components::getSingleton ().findComponent (BASEAPP_TYPE, bestBaseappID_);
297
307
298
308
if (cinfos == NULL || cinfos->pChannel == NULL )
@@ -330,7 +340,16 @@ void Baseappmgr::registerPendingAccountToBaseappAddr(Mercury::Channel* pChannel,
330
340
DEBUG_MSG (fmt::format (" Baseappmgr::registerPendingAccountToBaseappAddr:{0}, componentID={1}, entityID={2}.\n " ,
331
341
accountName, componentID, entityID));
332
342
333
- Components::ComponentInfos* cinfos = Components::getSingleton ().findComponent (componentID);
343
+ Components::ComponentInfos* cinfos = Components::getSingleton ().findComponent (pChannel);
344
+ if (cinfos == NULL || cinfos->pChannel == NULL )
345
+ {
346
+ ERROR_MSG (" Baseappmgr::registerPendingAccountToBaseapp: not found loginapp!\n " );
347
+ return ;
348
+ }
349
+
350
+ pending_logins_[loginName] = cinfos->cid ;
351
+
352
+ cinfos = Components::getSingleton ().findComponent (componentID);
334
353
if (cinfos == NULL || cinfos->pChannel == NULL )
335
354
{
336
355
ERROR_MSG (fmt::format (" Baseappmgr::registerPendingAccountToBaseappAddr: not found baseapp({}).\n " , componentID));
@@ -356,26 +375,30 @@ void Baseappmgr::onPendingAccountGetBaseappAddr(Mercury::Channel* pChannel,
356
375
void Baseappmgr::sendAllocatedBaseappAddr (Mercury::Channel* pChannel,
357
376
std::string& loginName, std::string& accountName, const std::string& addr, uint16 port)
358
377
{
359
- Components::COMPONENTS& components = Components::getSingleton ().getComponents (LOGINAPP_TYPE);
360
- size_t componentSize = components.size ();
378
+ KBEUnordered_map< std::string, COMPONENT_ID >::iterator iter = pending_logins_.find (loginName);
379
+ if (iter == pending_logins_.end ())
380
+ {
381
+ ERROR_MSG (" Baseappmgr::sendAllocatedBaseappAddr: not found loginapp, pending_logins is error!\n " );
382
+ return ;
383
+ }
361
384
362
- if (componentSize == 0 )
385
+ Components::ComponentInfos* cinfos = Components::getSingleton ().findComponent (iter->second );
386
+ if (cinfos == NULL || cinfos->pChannel == NULL )
363
387
{
364
- ERROR_MSG (" Baseappmgr::sendAllocatedBaseappAddr: not found loginapp. \n " );
388
+ ERROR_MSG (" Baseappmgr::sendAllocatedBaseappAddr: not found loginapp! \n " );
365
389
return ;
366
390
}
367
391
368
- Components::COMPONENTS::iterator iter = components.begin ();
369
- Mercury::Channel* lpChannel = (*iter).pChannel ;
370
-
371
392
Mercury::Bundle* pBundleToLoginapp = Mercury::Bundle::ObjPool ().createObject ();
372
393
(*pBundleToLoginapp).newMessage (LoginappInterface::onLoginAccountQueryBaseappAddrFromBaseappmgr);
373
394
374
395
LoginappInterface::onLoginAccountQueryBaseappAddrFromBaseappmgrArgs4::staticAddToBundle ((*pBundleToLoginapp), loginName,
375
396
accountName, addr, port);
376
397
377
- (*pBundleToLoginapp).send (this ->networkInterface (), lpChannel );
398
+ (*pBundleToLoginapp).send (this ->networkInterface (), cinfos-> pChannel );
378
399
Mercury::Bundle::ObjPool ().reclaimObject (pBundleToLoginapp);
400
+
401
+ pending_logins_.erase (iter);
379
402
}
380
403
381
404
// -------------------------------------------------------------------------------------
0 commit comments