This commit is contained in:
aozhiwei 2019-07-30 15:50:15 +08:00
parent e1bb53b150
commit 30a76daeb7
5 changed files with 49 additions and 12 deletions

View File

@ -2,4 +2,4 @@
cd ../tools/robot/virtualclient
#python robot.py ws://192.168.100.21:7101 hao1069 hao1069 $1
python robot.py "wss://game2001-test.kingsome.cn" hao1069 hao1069 $1
python robot.py "wss://game2001.kingsome.cn" hao1069 hao1069 $1

View File

@ -53,12 +53,16 @@ const char* const PROJ_LOG_FILENAME_FMT = "log_$pid_%Y%m%d.log";
static void SavePerfLog()
{
a8::UdpLog::Instance()->Info("max_mainloop_rundelay:%d room_num:%d player_num:%d online_num:%d",
a8::UdpLog::Instance()->Info("max_mainloop_rundelay:%d room_num:%d player_num:%d online_num:%d max_http_time:%d "
"max_request_delay:%d http_pending_num:%d",
{
App::Instance()->perf.max_run_delay_time,
RoomMgr::Instance()->RoomNum(),
App::Instance()->perf.entity_num[ET_Player],
PlayerMgr::Instance()->OnlineNum()
PlayerMgr::Instance()->OnlineNum(),
App::Instance()->perf.max_http_time,
f8::HttpClientPool::Instance()->max_request_delay,
f8::HttpClientPool::Instance()->GetPendingNum()
});
if (App::Instance()->HasFlag(4)) {
a8::XPrintf("mainloop_time:%d netmsg_time:%d room:%d over_room:%d online:%d bullet:%d grid_chg_times:%d test_times:%d ray_times:%d ray_time:%d send_node_num:%d sent_node_num:%d sent_bytes_num:%d\n",
@ -102,6 +106,7 @@ static void SavePerfLog()
App::Instance()->perf.params[4] = 0,
App::Instance()->perf.params[5] = 0,
App::Instance()->perf.params[6] = 0,
App::Instance()->perf.max_http_time = 0;
f8::HttpClientPool::Instance()->max_request_delay = 0;
}

View File

@ -12,6 +12,7 @@ struct PerfMonitor
long long test_times = 0;
long long ray_times = 0;
long long ray_time = 0;
long long max_http_time = 0;
std::array<long long, 30> params = {};
std::array<int, 30> entity_num = {};
};

View File

@ -61,11 +61,13 @@ g_account_id = '6000_1008_' + sys.argv[2]
g_session_id = sys.argv[3]
g_server_id = sys.argv[4]
g_seqid = 1000
g_login_time = time.time()
g_active_player_id = 0
recv_buf = bytearray()
def sendMsg(ws, msg):
print(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f'))
# print(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f'))
global g_seqid
++g_seqid
msgid = eval('cs_msgid_pb2._' + msg.DESCRIPTOR.name)
@ -80,15 +82,20 @@ def sendMsg(ws, msg):
buff = pktlen_str + msgid_str + seqid_str + sign_str + reserved_str + enmsg
ws.send (buff, 2)
print(time.time(), time.strftime('[%H:%M:%S]'), msg.DESCRIPTOR.name + '{')
print(str(msg),)
print('}')
print('')
# print(time.time(), time.strftime('[%H:%M:%S]'), msg.DESCRIPTOR.name + '{')
# print(str(msg),)
# print('}')
# print('')
def sendCMMove(ws):
msg = cs_proto_pb2.CMMove()
msg.spectate = True
sendMsg(ws, msg)
def onMessage(ws, message):
global recv_buf
print('onMessage', len(message))
# print('onMessage', len(message))
data = bytearray(message)
recv_buf += data
parserPacket(ws)
@ -109,8 +116,32 @@ def parserPacket(ws):
onUserPacket(ws, msgid, msgbody)
recv_buf = recv_buf[12 + pktlen:]
def procSMUpdate(msg):
global g_active_player_id
if msg.active_player_id != 0:
g_active_player_id = msg.active_player_id
print(g_active_player_id)
for part_obj in msg.part_objects:
if part_obj.object_type == 1 and part_obj.union_obj_1.obj_uniid == g_active_player_id:
pass
# print(part_obj)
for full_obj in msg.full_objects:
if full_obj.object_type == 1 and full_obj.union_obj_1.obj_uniid == g_active_player_id:
if full_obj.union_obj_1.dead:
print(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f'))
print(full_obj)
def onUserPacket(ws, msgid, msgbody):
global g_login_time
if time.time() - g_login_time > 30:
sendCMMove(ws)
try:
if msgid == 1004:
msg = getSMMsg(msgid)
ret = msg.ParseFromString(msgbody)
procSMUpdate(msg)
if msgid != 1009 and msgid != 1005:
return
print(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f'))
msg = getSMMsg(msgid)
ret = msg.ParseFromString(msgbody)
@ -138,7 +169,7 @@ def opOpen (ws):
msg = cs_proto_pb2.CMJoin()
msg.server_id = int(g_server_id)
msg.account_id = g_account_id
msg.name = "测试"
msg.name = "aozhwei12345678"
print(msg.DESCRIPTOR.name, 'zzzzz')
sendMsg(ws, msg)
while True:
@ -152,7 +183,7 @@ print(time.time())
print(g_remote_ip)
if __name__ == "__main__":
websocket.enableTrace(True)
# websocket.enableTrace(True)
ws = websocket.WebSocketApp (g_remote_ip,
on_message = onMessage,
on_error = onError,

@ -1 +1 @@
Subproject commit dd38a6a7c75ae7c880b6f2103763c2709abad920
Subproject commit 21332b63ad3066027c004aae21cfb277283bf985