1 // NeLNS - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include "nel/misc/types_nl.h"
18 #include "nel/misc/singleton.h"
20 #include "nel/net/module_manager.h"
21 #include "nel/net/module_builder_parts.h"
23 #include "welcome_service_itf.h"
25 std::string
lsChooseShard (const std::string
&userName
,
26 const NLNET::CLoginCookie
&cookie
,
27 const std::string
&userPriv
,
28 const std::string
&userExtended
,
29 WS::TUserRole userRole
,
34 bool disconnectClient(uint32 userId
);
39 // welcome service module
40 class CWelcomeServiceMod
:
41 public NLNET::CEmptyModuleCommBehav
<NLNET::CEmptyModuleServiceBehav
<NLNET::CEmptySocketBehav
<NLNET::CModuleBase
> > >,
42 public WS::CWelcomeServiceSkel
,
43 public NLMISC::CManualSingleton
<CWelcomeServiceMod
>
45 /// the ring session manager module (if any)
46 NLNET::TModuleProxyPtr _RingSessionManager
;
47 /// the login service module (if any)
48 NLNET::TModuleProxyPtr _LoginService
;
50 void onModuleUp(NLNET::IModuleProxy
*proxy
);
51 void onModuleDown(NLNET::IModuleProxy
*proxy
);
54 ////// CWelcomeServiceSkel implementation
56 // ask the welcome service to welcome a user
57 virtual void welcomeUser(NLNET::IModuleProxy
*sender
, uint32 userId
, const std::string
&userName
, const NLNET::CLoginCookie
&cookie
, const std::string
&priviledge
, const std::string
&exPriviledge
, WS::TUserRole mode
, uint32 instanceId
);
59 // ask the welcome service to disconnect a user
60 virtual void disconnectUser(NLNET::IModuleProxy
*sender
, uint32 userId
)
62 disconnectClient(userId
);
68 CWelcomeServiceSkel::init(this);
71 void reportWSOpenState(bool shardOpen
)
73 if (_RingSessionManager
== NULL
) // skip if the RSM is offline
76 CWelcomeServiceClientProxy
wscp(_RingSessionManager
);
77 wscp
.reportWSOpenState(this, shardOpen
);
80 // forward response from the front end for a player slot to play in
81 // to the client of this welcome service (usually the Ring Session Manager)
82 void frontendResponse(NLNET::IModuleProxy
*waiterModule
, uint32 userId
, const std::string
&reason
, const NLNET::CLoginCookie
&cookie
, const std::string
&fsAddr
)
84 CWelcomeServiceClientProxy
wscp(waiterModule
);
85 wscp
.welcomeUserResult(this, userId
, reason
.empty(), fsAddr
, reason
);
88 // send the current number of players on this shard to the Ring Session Manager
89 void updateConnectedPlayerCount(uint32 nbOnlinePlayers
, uint32 nbPendingPlayers
)
91 if (_RingSessionManager
== NULL
) // skip if the RSM is offline
94 CWelcomeServiceClientProxy
wscp(_RingSessionManager
);
95 wscp
.updateConnectedPlayerCount(this, nbOnlinePlayers
, nbPendingPlayers
);
98 // inform the LS that a pending client is lost
99 void pendingUserLost(const NLNET::CLoginCookie
&cookie
);
102 struct TPendingFEResponseInfo
104 CWelcomeServiceMod
*WSMod
;
105 NLNET::TModuleProxyPtr WaiterModule
;
108 typedef std::map
<NLNET::CLoginCookie
, TPendingFEResponseInfo
> TPendingFeReponses
;
109 // the list of cookie string that are pending an
110 TPendingFeReponses PendingFeResponse
;