Skip to content

Commit

Permalink
netclient优化
Browse files Browse the repository at this point in the history
  • Loading branch information
xiyoo0812 committed Sep 28, 2023
1 parent 1e7ede9 commit 3243202
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions script/constant.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
local KernCode = enum("KernCode", 0)
KernCode.SUCCESS = 0 --成功
KernCode.FAILED = 1 --系统错误,请重试
KernCode.PARAM_ERROR = 2 --业务参数错误
KernCode.TOO_FAST = 3 --操作太快
KernCode.TOO_FAST = 2 --操作太快
KernCode.PARAM_ERROR = 3 --业务参数错误
KernCode.UPHOLD = 4 --服务维护
KernCode.RPC_FAILED = 5 --RPC调用失败
KernCode.OPERATOR_SELF = 6 --不能对自己操作
Expand Down
2 changes: 1 addition & 1 deletion script/network/net_client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function NetClient:write(cmd_id, data, type, session_id, flag)
return false
end
-- call lbus
local send_len = self.socket.call_pb(cmd_id, flag, type, session_id, data)
local send_len = self.socket.call_pb(session_id, cmd_id, flag, type, 0, data)
if send_len < 0 then
log_err("[NetClient][write] call_pb failed! code:%s", send_len)
return false
Expand Down
2 changes: 1 addition & 1 deletion script/network/net_server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function NetServer:on_socket_accept(session)
end
session.on_call_pb = function(recv_len, session_id, cmd_id, flag, type, crc8, body)
local now_ms = quanta.now_ms
if session.lc_crc == crc8 and now_ms - session.lc_time < FAST_MS then
if crc8 > 0 and session.lc_crc == crc8 and now_ms - session.lc_time < FAST_MS then
self:callback_errcode(session, cmd_id, TOO_FAST, session_id)
return
end
Expand Down

0 comments on commit 3243202

Please sign in to comment.