Repository navigation
Expand file tree
/
Copy pathclientobject.h
More file actions
122 lines (95 loc) · 3.18 KB
/
Copy pathclientobject.h
File metadata and controls
122 lines (95 loc) · 3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
This source file is part of KBEngine
For the latest info, see http://www.kbengine.org/
Copyright (c) 2008-2016 KBEngine.
KBEngine is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
KBEngine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with KBEngine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KBE_CLIENT_OBJECT_H
#define KBE_CLIENT_OBJECT_H
#include "tcp_packet_receiver_ex.h"
#include "tcp_packet_sender_ex.h"
#include "client_lib/entity.h"
#include "client_lib/clientobjectbase.h"
#include "network/encryption_filter.h"
#include "pyscript/pyobject_pointer.h"
namespace KBEngine{
/*
*/
class ClientObject : public ClientObjectBase
{
/**
子类化 将一些py操作填充进派生类
*/
INSTANCE_SCRIPT_HREADER(ClientObject, ClientObjectBase)
public:
enum C_ERROR
{
C_ERROR_NONE = 0,
C_ERROR_INIT_NETWORK_FAILED = 1,
C_ERROR_CREATE_FAILED = 2,
C_ERROR_LOGIN_FAILED = 3,
C_ERROR_LOGIN_BASEAPP_FAILED = 4,
};
enum C_STATE
{
C_STATE_INIT = 0,
C_STATE_CREATE = 1,
C_STATE_LOGIN = 2,
C_STATE_LOGIN_BASEAPP_CREATE = 3,
C_STATE_LOGIN_BASEAPP = 4,
C_STATE_PLAY = 5,
C_STATE_DESTROYED = 6,
};
ClientObject(std::string name, Network::NetworkInterface& ninterface);
virtual ~ClientObject();
virtual void finalise();
virtual void reset(void);
bool initCreate();
bool initLoginBaseapp();
void gameTick();
ClientObject::C_ERROR lasterror(){ return error_; }
bool isDestroyed(){ return state_ == C_STATE_DESTROYED; }
void destroy(){ state_ = C_STATE_DESTROYED; }
virtual void onHelloCB_(Network::Channel* pChannel, const std::string& verInfo,
const std::string& scriptVerInfo, const std::string& protocolMD5,
const std::string& entityDefMD5, COMPONENT_TYPE componentType);
/** 网络接口
创建账号成功和失败回调
@failedcode: 失败返回码 NETWORK_ERR_SRV_NO_READY:服务器没有准备好,
NETWORK_ERR_ACCOUNT_CREATE:创建失败(已经存在),
NETWORK_SUCCESS:账号创建成功
SERVER_ERROR_CODE failedcode;
@二进制附带数据:二进制额外数据: uint32长度 + bytearray
*/
virtual void onCreateAccountResult(Network::Channel * pChannel, MemoryStream& s);
/** 网络接口
登录失败回调
@failedcode: 失败返回码 NETWORK_ERR_SRV_NO_READY:服务器没有准备好,
NETWORK_ERR_SRV_OVERLOAD:服务器负载过重,
NETWORK_ERR_NAME_PASSWORD:用户名或者密码不正确
*/
virtual void onLoginFailed(Network::Channel * pChannel, MemoryStream& s);
/** 网络接口
登录成功
@ip: 服务器ip地址
@port: 服务器端口
*/
virtual void onLoginSuccessfully(Network::Channel * pChannel, MemoryStream& s);
protected:
C_ERROR error_;
C_STATE state_;
Network::BlowfishFilter* pBlowfishFilter_;
Network::TCPPacketSenderEx* pTCPPacketSenderEx_;
Network::TCPPacketReceiverEx* pTCPPacketReceiverEx_;
};
}
#endif // KBE_CLIENT_OBJECT_H