1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef SESSION_BROWSER_IMPL_H
21 #define SESSION_BROWSER_IMPL_H
24 #include "session_browser.h"
25 #include "game_share/ring_session_manager_itf.h"
26 #include "nel/gui/lua_helper.h"
29 class CSessionBrowserImpl
: public CSessionBrowser
,
30 public NLMISC::CSingleton
<CSessionBrowserImpl
>
33 /** Register access to session browser from lua (from the 'game' table)
35 * game.getSessionList() -> send a request to server to get the list of session
37 * On success, RingAccessPoint:fill() will be called with a table containing the result of the request
38 * On failure : - RingAccessPoint:onDisconnection()
39 * - RingAccessPoint:onConnectionClosed()
40 * - RingAccessPoint:onConnectionFailed()
42 void init(NLGUI::CLuaState
*ls
);
43 // from CSessionBrowser
44 virtual void on_connectionFailed();
45 virtual void on_connectionClosed();
46 virtual void on_CRingSessionManagerWebClient_Disconnection(NLNET::TSockId from
);
47 virtual void on_invokeResult(NLNET::TSockId from
, uint32 userId
, uint32 resultCode
, const std::string
&resultString
);
48 virtual void on_scheduleSessionResult(NLNET::TSockId from
, uint32 charId
, TSessionId sessionId
, uint8 result
, const std::string
&resultString
);
49 virtual void on_sessionInfoResult(NLNET::TSockId from
, uint32 charId
, TSessionId sessionId
, const RSMGR::TRaceFilter
&raceFilter
, const RSMGR::TReligionFilter
&religionFilter
,
50 const RSMGR::TGuildFilter
&guildFilter
, const RSMGR::TShardFilter
&shardFilter
, const RSMGR::TLevelFilter
&levelFilter
, bool subscriptionClosed
, bool autoInvite
, const std::string
&language
, const RSMGR::TSessionOrientation
&orientation
, const std::string
&description
);
51 virtual void on_joinSessionResult(NLNET::TSockId from
, uint32 userId
, TSessionId sessionId
, uint32 result
, const std::string
&shardAddr
, const RSMGR::TSessionPartStatus
&participantStatus
);
52 virtual void on_joinSessionResultExt(NLNET::TSockId from
, uint32 userId
, TSessionId sessionId
, uint32 result
, const std::string
&shardAddr
, const RSMGR::TSessionPartStatus
&participantStatus
, const CSecurityCode
& securityCode
);
53 virtual void on_getShardsResult(NLNET::TSockId from
, uint32 userId
, const std::string
&result
);
54 virtual void on_CSessionBrowserServerWebClient_Disconnection(NLNET::TSockId from
);
55 virtual void on_sessionList(NLNET::TSockId from
, uint32 charId
, const std::vector
< RSMGR::TSessionDesc
> &sessions
);
56 virtual void on_charList(NLNET::TSockId from
, uint32 charId
, TSessionId sessionId
, const std::vector
< RSMGR::TCharDesc
> &charDescs
);
57 virtual void on_playerRatings(NLNET::TSockId from
, uint32 charId
, bool scenarioRated
, uint32 rateFun
, uint32 rateDifficulty
, uint32 rateAccessibility
, uint32 rateOriginality
, uint32 rateDirection
);
58 virtual void on_ringRatings(NLNET::TSockId from
, uint32 charId
, uint32 authorRating
, uint32 AMRating
, uint32 masterlessRating
);
59 virtual void on_ringPoints(NLNET::TSockId from
, uint32 charId
, const std::string
&ringPoints
, const std::string
&maxRingPoints
);
60 // Return average scores of a session
61 virtual void on_sessionAverageScores(NLNET::TSockId from
, bool scenarioRated
, uint32 rateFun
, uint32 rateDifficulty
, uint32 rateAccessibility
, uint32 rateOriginality
, uint32 rateDirection
, uint32 rrpTotal
);
62 virtual void on_scenarioAverageScores(NLNET::TSockId from
, bool scenarioRated
, uint32 rateFun
, uint32 rateDifficulty
, uint32 rateAccessibility
, uint32 rateOriginality
, uint32 rateDirection
, uint32 rrpTotal
);
64 static uint32
getCharId();
66 // tmp, for local test
72 uint32 _LastInvokeResult
;
73 std::string _LastInvokeResultMsg
;
75 uint32 _LastJoinSessionResult
;
76 TSessionId _LastJoinSessionId
;
77 std::string _LastJoinSessionShardAddr
;
78 RSMGR::TSessionPartStatus _LastJoinSessionPartStatus
;
80 uint32 _LastScheduleSessionCharId
;
81 uint32 _LastScheduleSessionResult
;
82 TSessionId _LastScheduleSessionId
;
83 std::string _LastScheduleSessionResulMsg
;
85 CFarTP::TJoinMode CurrentJoinMode
;
87 RSMGR::TRaceFilter _LastRaceFilter
;
88 RSMGR::TReligionFilter _LastReligionFilter
;
89 RSMGR::TGuildFilter _LastGuildFilter
;
90 RSMGR::TShardFilter _LastShardFilter
;
91 RSMGR::TLevelFilter _LastLevelFilter
;
92 bool _LastSubscriptionClosed
;
94 std::string _LastDescription
;
96 uint32 _LastAuthorRating
;
98 uint32 _LastMasterlessRating
;
99 std::string _LastRingPoints
;
100 std::string _LastMaxRingPoints
;
102 static const std::string
&getFrontEndAddress();
104 NLGUI::CLuaState::TRefPtr _Lua
;
105 static int luaGetRingSessionList(NLGUI::CLuaState
&ls
);
106 static int luaGetRingCharList(NLGUI::CLuaState
&ls
);
107 static int luaJoinRingSession(NLGUI::CLuaState
&ls
);
108 static int luaCheckRingAccess(NLGUI::CLuaState
&ls
);
109 static int luaGetFileHeader(NLGUI::CLuaState
&ls
);
110 static int luaGetRingStats(NLGUI::CLuaState
&ls
);
111 static int luaGetScenarioScores(NLGUI::CLuaState
&ls
);
112 static int luaUpdateScenarioScores(NLGUI::CLuaState
&ls
);
113 static int luaGetSessionAverageScores(NLGUI::CLuaState
&ls
);
114 static int luaGetScenarioAverageScores(NLGUI::CLuaState
&ls
);
115 // Call a method inside the 'RingAccessPoint' lua table
116 void callRingAccessPointMethod(const char *name
, int numArg
, int numResult
);
117 void callRingCharTrackingMethod(const char *name
, int numArg
, int numResult
);
118 void callRingPlayerInfoMethod(const char *name
, int numArg
, int numResult
);
119 void callScenarioScoresMethod(const char *name
, int numArg
, int numResult
);
121 void fill(const std::vector
<RSMGR::TSessionDesc
> &sessions
);
122 void charsFill(const std::vector
<RSMGR::TCharDesc
> &chars
);
123 void ringStatsFill();
124 void playerRatingFill(bool scenarioRated
, uint32 rateFun
, uint32 rateDifficulty
, uint32 rateAccessibility
, uint32 rateOriginality
, uint32 rateDirection
);
125 void averageScoresFill(bool scenarioRated
, uint32 rateFun
, uint32 rateDifficulty
, uint32 rateAccessibility
, uint32 rateOriginality
, uint32 rateDirection
, uint32 rrpTotal
);
127 static const NLNET::CLoginCookie
&getCookie();
131 #endif //SESSION_BROWSER_H