@@ -28,6 +28,8 @@ along with KBEngine. If not, see <http://www.gnu.org/licenses/>.
2828#include " network/channel.hpp"
2929#include " network/bundle.hpp"
3030
31+ #include " tools/billing_system/billingsystem_interface.hpp"
32+
3133namespace KBEngine {
3234
3335// -------------------------------------------------------------------------------------
@@ -71,25 +73,35 @@ BillingHandler_Normal::~BillingHandler_Normal()
7173}
7274
7375// -------------------------------------------------------------------------------------
74- bool BillingHandler_Normal::createAccount (Mercury::Channel* pChannel, std::string& accountName ,
76+ bool BillingHandler_Normal::createAccount (Mercury::Channel* pChannel, std::string& registerName ,
7577 std::string& password, std::string& datas)
7678{
7779 dbThreadPool_.addTask (new DBTaskCreateAccount (pChannel->addr (),
78- accountName , password, datas));
80+ registerName, registerName , password, datas));
7981
8082 return true ;
8183}
8284
85+ // -------------------------------------------------------------------------------------
86+ void BillingHandler_Normal::onCreateAccountCB (KBEngine::MemoryStream& s)
87+ {
88+ }
89+
8390// -------------------------------------------------------------------------------------
8491bool BillingHandler_Normal::loginAccount (Mercury::Channel* pChannel, std::string& loginName,
8592 std::string& password, std::string& datas)
8693{
8794 dbThreadPool_.addTask (new DBTaskAccountLogin (pChannel->addr (),
88- loginName, password, datas));
95+ loginName, loginName, password, datas));
8996
9097 return true ;
9198}
9299
100+ // -------------------------------------------------------------------------------------
101+ void BillingHandler_Normal::onLoginAccountCB (KBEngine::MemoryStream& s)
102+ {
103+ }
104+
93105// -------------------------------------------------------------------------------------
94106BillingHandler_ThirdParty::BillingHandler_ThirdParty (thread::ThreadPool& threadPool, DBThreadPool& dbThreadPool):
95107BillingHandler_Normal (threadPool, dbThreadPool),
@@ -105,33 +117,91 @@ BillingHandler_ThirdParty::~BillingHandler_ThirdParty()
105117}
106118
107119// -------------------------------------------------------------------------------------
108- bool BillingHandler_ThirdParty::createAccount (Mercury::Channel* pChannel, std::string& accountName ,
120+ bool BillingHandler_ThirdParty::createAccount (Mercury::Channel* pChannel, std::string& registerName ,
109121 std::string& password, std::string& datas)
110122{
111123 KBE_ASSERT (pBillingChannel_);
112124
113- Mercury::Bundle bundle;
114- bundle << accountName << password;
115- bundle.appendBlob (datas);
125+ Mercury::Bundle::SmartPoolObjectPtr bundle = Mercury::Bundle::createSmartPoolObj ();
126+
127+ (*(*bundle)).newMessage (BillingSystemInterface::reqCreateAccount);
128+ (*(*bundle)) << pChannel->componentID ();
129+ (*(*bundle)) << registerName << password;
130+ (*(*bundle)).appendBlob (datas);
116131
117- bundle.send (Dbmgr::getSingleton ().getNetworkInterface (), pBillingChannel_);
132+ (*(* bundle)) .send (Dbmgr::getSingleton ().getNetworkInterface (), pBillingChannel_);
118133 return true ;
119134}
120135
136+ // -------------------------------------------------------------------------------------
137+ void BillingHandler_ThirdParty::onCreateAccountCB (KBEngine::MemoryStream& s)
138+ {
139+ std::string registerName, accountName, password, datas;
140+ COMPONENT_ID cid;
141+ bool success = false ;
142+
143+ s >> cid >> registerName >> accountName >> password >> success;
144+ s.readBlob (datas);
145+
146+ if (!success)
147+ {
148+ accountName = " " ;
149+ }
150+
151+ Components::ComponentInfos* cinfos = Components::getSingleton ().findComponent (LOGINAPP_TYPE , cid);
152+ if (cinfos == NULL || cinfos->pChannel == NULL )
153+ {
154+ ERROR_MSG (" BillingHandler_ThirdParty::onCreateAccountCB: loginapp not found!\n " );
155+ return ;
156+ }
157+
158+ dbThreadPool_.addTask (new DBTaskCreateAccount (cinfos->pChannel ->addr (),
159+ registerName, accountName, password, datas));
160+ }
161+
121162// -------------------------------------------------------------------------------------
122163bool BillingHandler_ThirdParty::loginAccount (Mercury::Channel* pChannel, std::string& loginName,
123164 std::string& password, std::string& datas)
124165{
125166 KBE_ASSERT (pBillingChannel_);
126167
127- Mercury::Bundle bundle;
128- bundle << loginName << password;
129- bundle.appendBlob (datas);
168+ Mercury::Bundle::SmartPoolObjectPtr bundle = Mercury::Bundle::createSmartPoolObj ();
169+
170+ (*(*bundle)).newMessage (BillingSystemInterface::onAccountLogin);
171+ (*(*bundle)) << pChannel->componentID ();
172+ (*(*bundle)) << loginName << password;
173+ (*(*bundle)).appendBlob (datas);
130174
131- bundle.send (Dbmgr::getSingleton ().getNetworkInterface (), pBillingChannel_);
175+ (*(* bundle)) .send (Dbmgr::getSingleton ().getNetworkInterface (), pBillingChannel_);
132176 return true ;
133177}
134178
179+ // -------------------------------------------------------------------------------------
180+ void BillingHandler_ThirdParty::onLoginAccountCB (KBEngine::MemoryStream& s)
181+ {
182+ std::string loginName, accountName, password, datas;
183+ COMPONENT_ID cid;
184+ bool success = false ;
185+
186+ s >> cid >> loginName >> accountName >> password >> success;
187+ s.readBlob (datas);
188+
189+ if (!success)
190+ {
191+ accountName = " " ;
192+ }
193+
194+ Components::ComponentInfos* cinfos = Components::getSingleton ().findComponent (LOGINAPP_TYPE , cid);
195+ if (cinfos == NULL || cinfos->pChannel == NULL )
196+ {
197+ ERROR_MSG (" BillingHandler_ThirdParty::onCreateAccountCB: loginapp not found!\n " );
198+ return ;
199+ }
200+
201+ dbThreadPool_.addTask (new DBTaskAccountLogin (cinfos->pChannel ->addr (),
202+ loginName, accountName, password, datas));
203+ }
204+
135205// -------------------------------------------------------------------------------------
136206bool BillingHandler_ThirdParty::initialize ()
137207{
@@ -202,6 +272,8 @@ bool BillingHandler_ThirdParty::reconnect()
202272 }
203273 }
204274
275+ // ²»¼ì²é³¬Ê±
276+ pBillingChannel_->stopInactivityDetection ();
205277 return true ;
206278}
207279
0 commit comments