Skip to content

Commit e1645dc

Browse files
committed
bots进一步完善. 目前可以注册账号、登录账号。
1 parent 464ad66 commit e1645dc

18 files changed

Lines changed: 657 additions & 193 deletions

‎kbe/src/lib/client_lib/client_interface.hpp‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ NETWORK_INTERFACE_DECLARE_BEGIN(ClientInterface)
5555
CLIENT_MESSAGE_DECLARE_STREAM(onLoginSuccessfully, MERCURY_VARIABLE_MESSAGE)
5656

5757
// 登录失败。
58-
CLIENT_MESSAGE_DECLARE_ARGS1(onLoginFailed, MERCURY_FIXED_MESSAGE,
59-
SERVER_ERROR_CODE, failedcode)
58+
CLIENT_MESSAGE_DECLARE_STREAM(onLoginFailed, MERCURY_FIXED_MESSAGE)
6059

6160
// 服务器端已经创建了一个与客户端关联的代理Entity || 登录网关成功。
6261
CLIENT_MESSAGE_DECLARE_ARGS3(onCreatedProxies, MERCURY_VARIABLE_MESSAGE,

‎kbe/src/lib/client_lib/clientapp.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ void ClientApp::onLoginSuccessfully(Mercury::Channel * pChannel, MemoryStream& s
167167
}
168168

169169
//-------------------------------------------------------------------------------------
170-
void ClientApp::onLoginFailed(Mercury::Channel * pChannel, SERVER_ERROR_CODE failedcode)
170+
void ClientApp::onLoginFailed(Mercury::Channel * pChannel, MemoryStream& s)
171171
{
172172
}
173173

‎kbe/src/lib/client_lib/clientapp.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class ClientApp :
125125
MERCURY_ERR_SRV_OVERLOAD:服务器负载过重,
126126
MERCURY_ERR_NAME_PASSWORD:用户名或者密码不正确
127127
*/
128-
virtual void onLoginFailed(Mercury::Channel * pChannel, SERVER_ERROR_CODE failedcode);
128+
virtual void onLoginFailed(Mercury::Channel * pChannel, MemoryStream& s);
129129

130130
/** 网络接口
131131
登录成功

‎kbe/src/lib/cstdkbe/cstdkbe.hpp‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,21 +172,26 @@ const COMPONENT_TYPE ALL_COMPONENT_TYPES[] = {BASEAPPMGR_TYPE, CELLAPPMGR_TYPE,
172172
enum COMPONENT_CLIENT_TYPE
173173
{
174174
UNKNOWN_CLIENT_COMPONENT_TYPE = 0,
175-
CLIENT_TYPE_PHONE = 1, // 手机类
175+
CLIENT_TYPE_MOBILE = 1, // 手机类
176176
CLIENT_TYPE_PC = 2, // pc, 一般都是exe客户端
177-
CLIENT_TYPE_WEB = 3 // web应用, html5,flash
177+
CLIENT_TYPE_BROWSER = 3, // web应用, html5,flash
178+
CLIENT_TYPE_BOTS = 4 // bots
178179
};
179180

180181
/** 定义前端应用的类别名称 */
181182
const char COMPONENT_CLIENT_NAME[][255] = {
182183
"UNKNOWN_CLIENT_COMPONENT_TYPE",
183-
"CLIENT_TYPE_PHONE",
184+
"CLIENT_TYPE_MOBILE",
184185
"CLIENT_TYPE_PC",
185-
"CLIENT_TYPE_WEB",
186+
"CLIENT_TYPE_BROWSER",
187+
"CLIENT_TYPE_BOTS",
186188
};
187189

188190
// 所有前端应用的类别
189-
const COMPONENT_CLIENT_TYPE ALL_CLIENT_TYPES[] = {CLIENT_TYPE_PHONE, CLIENT_TYPE_PC, CLIENT_TYPE_WEB, UNKNOWN_CLIENT_COMPONENT_TYPE};
191+
const COMPONENT_CLIENT_TYPE ALL_CLIENT_TYPES[] = {CLIENT_TYPE_MOBILE, CLIENT_TYPE_PC, CLIENT_TYPE_BROWSER,
192+
CLIENT_TYPE_BOTS, UNKNOWN_CLIENT_COMPONENT_TYPE};
193+
194+
typedef int8 CLIENT_CTYPE;
190195

191196
// 前端是否支持浮点数
192197
#define CLIENT_NO_FLOAT

‎kbe/src/server/baseapp/proxy.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ void Proxy::giveClientTo(Proxy* proxy)
211211
{
212212
// 通知cell丢失客户端
213213
Mercury::Bundle* pBundle = Mercury::Bundle::ObjPool().createObject();
214-
(*pBundle).newMessage(CellappInterface::onLoseWitness);
214+
(*pBundle).newMessage(CellappInterface::onResetWitness);
215215
(*pBundle) << this->getID();
216216
getCellMailbox()->postMail((*pBundle));
217217
Mercury::Bundle::ObjPool().reclaimObject(pBundle);

‎kbe/src/server/cellapp/cellapp_interface.hpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ NETWORK_INTERFACE_DECLARE_BEGIN(CellappInterface)
170170
//entity丢失了一个观察者(客户端)
171171
ENTITY_MESSAGE_DECLARE_ARGS0(onLoseWitness, MERCURY_FIXED_MESSAGE)
172172

173+
//entity 观察者重置(客户端)通常是由于客户端重新绑定造成的
174+
ENTITY_MESSAGE_DECLARE_ARGS0(onResetWitness, MERCURY_FIXED_MESSAGE)
175+
173176
// entity传送。
174177
ENTITY_MESSAGE_DECLARE_ARGS3(teleportFromBaseapp, MERCURY_FIXED_MESSAGE,
175178
COMPONENT_ID, cellAppID,

‎kbe/src/server/cellapp/entity.cpp‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,12 @@ void Entity::onLoseWitness(Mercury::Channel* pChannel)
774774
SCRIPT_OBJECT_CALL_ARGS0(this, const_cast<char*>("onLoseWitness"));
775775
}
776776

777+
//-------------------------------------------------------------------------------------
778+
void Entity::onResetWitness(Mercury::Channel* pChannel)
779+
{
780+
INFO_MSG(boost::format("%1%::onResetWitness: %2%.\n") % this->getScriptName() % this->getID());
781+
}
782+
777783
//-------------------------------------------------------------------------------------
778784
int32 Entity::setAoiRadius(float radius, float hyst)
779785
{

‎kbe/src/server/cellapp/entity.hpp‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,12 @@ class Entity : public script::ScriptObject
322322
*/
323323
void onLoseWitness(Mercury::Channel* pChannel);
324324

325+
/** 网络接口
326+
entity丢失了一个观察者(客户端)
327+
328+
*/
329+
void onResetWitness(Mercury::Channel* pChannel);
330+
325331
/**
326332
添加一个陷阱
327333
*/

‎kbe/src/server/cellapp/witness.cpp‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ Witness::~Witness()
2727
//-------------------------------------------------------------------------------------
2828
void Witness::attach(Entity* pEntity)
2929
{
30+
DEBUG_MSG(boost::format("Witness::attach: %1%(%2%).") %
31+
pEntity->getScriptName() % pEntity->getID());
32+
3033
pEntity_ = pEntity;
3134

3235
// 初始化默认AOI范围
@@ -39,6 +42,9 @@ void Witness::attach(Entity* pEntity)
3942
//-------------------------------------------------------------------------------------
4043
void Witness::detach(Entity* pEntity)
4144
{
45+
DEBUG_MSG(boost::format("Witness::detach: %1%(%2%).") %
46+
pEntity->getScriptName() % pEntity->getID());
47+
4248
pEntity_ = NULL;
4349
aoiRadius_ = 0.0f;
4450
aoiHysteresisArea_ = 0.0f;

‎kbe/src/server/loginapp/loginapp.cpp‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,16 @@ void Loginapp::onDbmgrInitCompleted(Mercury::Channel* pChannel, int32 startGloba
134134
startGroupOrder_ = startGroupOrder;
135135
}
136136

137+
138+
//-------------------------------------------------------------------------------------
139+
void Loginapp::onClientActiveTick(Mercury::Channel* pChannel)
140+
{
141+
if(!pChannel->isExternal())
142+
return;
143+
144+
onAppActiveTick(pChannel, CLIENT_TYPE, 0);
145+
}
146+
137147
//-------------------------------------------------------------------------------------
138148
void Loginapp::reqCreateAccount(Mercury::Channel* pChannel, MemoryStream& s)
139149
{
@@ -224,7 +234,7 @@ void Loginapp::onReqCreateAccountResult(Mercury::Channel* pChannel, MemoryStream
224234
void Loginapp::login(Mercury::Channel* pChannel, MemoryStream& s)
225235
{
226236
COMPONENT_CLIENT_TYPE ctype;
227-
int8 tctype = 0;
237+
CLIENT_CTYPE tctype = UNKNOWN_CLIENT_COMPONENT_TYPE;
228238
std::string loginName;
229239
std::string password;
230240
std::string datas;

0 commit comments

Comments
 (0)