Commit 8474ca362f0466e3e24cc9c60c3ea8ad02f21b6a
1 parent
5dfc4978
聊天
Showing
4 changed files
with
52 additions
and
30 deletions
Show diff stats
src/actions/FriendAction.lua
@@ -307,7 +307,7 @@ function _M.handleApplyRpc(agent, data) | @@ -307,7 +307,7 @@ function _M.handleApplyRpc(agent, data) | ||
307 | 307 | ||
308 | redisproxy:pipelining(function (red) | 308 | redisproxy:pipelining(function (red) |
309 | red:ZREM(FRIEND_APPLY_KEY:format(roleId), table_unpack(needAdd)) | 309 | red:ZREM(FRIEND_APPLY_KEY:format(roleId), table_unpack(needAdd)) |
310 | - red:hsetnx(FRIEND_KEY:format(roleId), table_unpack(needAddMy)) | 310 | + red:HMSET(FRIEND_KEY:format(roleId), table_unpack(needAddMy)) |
311 | for _, objectId in pairs(needAdd) do | 311 | for _, objectId in pairs(needAdd) do |
312 | red:ZREM(FRIEND_APPLY_KEY:format(objectId), roleId) | 312 | red:ZREM(FRIEND_APPLY_KEY:format(objectId), roleId) |
313 | red:hsetnx(FRIEND_KEY:format(objectId), roleId, newTag)--告知对放有新好友 | 313 | red:hsetnx(FRIEND_KEY:format(objectId), roleId, newTag)--告知对放有新好友 |
@@ -577,7 +577,7 @@ function _M.pointRpc(agent, data) | @@ -577,7 +577,7 @@ function _M.pointRpc(agent, data) | ||
577 | reward = role:award({[ItemId.FriendPoint] = getCount}) | 577 | reward = role:award({[ItemId.FriendPoint] = getCount}) |
578 | role.dailyData:updateProperty({field = "getFP", value = getP}) | 578 | role.dailyData:updateProperty({field = "getFP", value = getP}) |
579 | else | 579 | else |
580 | - result = result + 2 | 580 | + result = (result or 0) + 2 |
581 | end | 581 | end |
582 | end | 582 | end |
583 | else | 583 | else |
src/actions/RoleAction.lua
@@ -601,27 +601,61 @@ function _M.chatRpc(agent, data) | @@ -601,27 +601,61 @@ function _M.chatRpc(agent, data) | ||
601 | time = now, | 601 | time = now, |
602 | } | 602 | } |
603 | 603 | ||
604 | - local check = { | ||
605 | - ["world"] = function () | 604 | + |
605 | + local waitTime = nil | ||
606 | + local check = { | ||
607 | + -- 世界聊天 | ||
608 | + [1] = function () | ||
606 | if role:getProperty("silent") > now then --禁言 | 609 | if role:getProperty("silent") > now then --禁言 |
607 | result = 1 | 610 | result = 1 |
608 | return | 611 | return |
609 | end | 612 | end |
613 | + | ||
614 | + role._worldChatLimit = role._worldChatLimit or {start = 0, count = 0, canSayt = 0} --第一次开始说话时间 从第一次说话次数 能说话的时间 | ||
615 | + | ||
616 | + if now < role._worldChatLimit.canSayt then | ||
617 | + result = 2 | ||
618 | + waitTime = canSayt - now | ||
619 | + return | ||
620 | + end | ||
621 | + | ||
622 | + if now - role._worldChatLimit.start >= globalCsv.chat_world_limit.time then | ||
623 | + role._worldChatLimit.start = now | ||
624 | + role._worldChatLimit.count = 1 | ||
625 | + else | ||
626 | + role._worldChatLimit.count = role._worldChatLimit.count + 1 | ||
627 | + if role._worldChatLimit.count > globalCsv.chat_world_limit.count then | ||
628 | + role._worldChatLimit.count = 0 | ||
629 | + role._worldChatLimit.start = 0 | ||
630 | + role._worldChatLimit.canSayt = now + globalCsv.chat_world_limit.wait | ||
631 | + result = 2 | ||
632 | + waitTime = globalCsv.chat_world_limit.wait | ||
633 | + return | ||
634 | + end | ||
635 | + end | ||
636 | + | ||
610 | mcast_util.pub_world(actionCodes.Role_chat, MsgPack.pack(response)) | 637 | mcast_util.pub_world(actionCodes.Role_chat, MsgPack.pack(response)) |
611 | pcall(skynet.call, 'GLOBALD', "lua", "sendWorldMsg", role._channelIdx, response) | 638 | pcall(skynet.call, 'GLOBALD', "lua", "sendWorldMsg", role._channelIdx, response) |
612 | end, | 639 | end, |
613 | - ["p2p"] = function () | ||
614 | - -- local result | ||
615 | - -- local objectId = msg.objectId | ||
616 | - -- if redisproxy:hexists(FRIEND_KEY:format(roleId), objectId) then | ||
617 | - -- response.to = objectId | ||
618 | - -- result = mcast_util.pub_person(agent.client_fd, objectId, actionCodes.Role_chat, MsgPack.pack(response)) | ||
619 | - -- else | ||
620 | - -- result = SYS_ERR_CHAT_NOT_FRIEND | ||
621 | - -- end | ||
622 | - -- if result then | ||
623 | - -- role:sendSysErrMsg(result) | ||
624 | - -- end | 640 | + -- 私聊 |
641 | + [2] = function () | ||
642 | + local objectId = msg.roleId | ||
643 | + | ||
644 | + if 0 == redisproxy:exists(string.format("role:%d", objectId)) then | ||
645 | + result = 1 | ||
646 | + return | ||
647 | + end | ||
648 | + | ||
649 | + -- 若在线,实时发送聊天信息 | ||
650 | + local agent = datacenter.get("agent", toRoleId) | ||
651 | + if not agent then | ||
652 | + result = 2 | ||
653 | + return | ||
654 | + end | ||
655 | + local bin = MsgPack.pack(response) | ||
656 | + SendPacket(actionCode, bin, agent.fd) | ||
657 | + SendPacket(actionCode, bin, fromFd) | ||
658 | + | ||
625 | end, | 659 | end, |
626 | } | 660 | } |
627 | if not check[cmd] then return end | 661 | if not check[cmd] then return end |
@@ -629,7 +663,7 @@ function _M.chatRpc(agent, data) | @@ -629,7 +663,7 @@ function _M.chatRpc(agent, data) | ||
629 | if not result then | 663 | if not result then |
630 | check[cmd]() | 664 | check[cmd]() |
631 | end | 665 | end |
632 | - SendPacket(actionCodes.Role_chatRpc, MsgPack.pack({result = result})) | 666 | + SendPacket(actionCodes.Role_chatRpc, MsgPack.pack({result = result, waitTime = waitTime})) |
633 | return true | 667 | return true |
634 | end | 668 | end |
635 | 669 |
src/models/Role.lua
@@ -196,6 +196,7 @@ function Role:data() | @@ -196,6 +196,7 @@ function Role:data() | ||
196 | loveStatus = self:getProperty("loveStatus"):toNumMap(), | 196 | loveStatus = self:getProperty("loveStatus"):toNumMap(), |
197 | diamond = self:getAllDiamond(), | 197 | diamond = self:getAllDiamond(), |
198 | bagLimit = self:getProperty("bagLimit"), | 198 | bagLimit = self:getProperty("bagLimit"), |
199 | + silent = self:getProperty("silent"), | ||
199 | 200 | ||
200 | advPass = self:getProperty("advPass"), | 201 | advPass = self:getProperty("advPass"), |
201 | advInfo = self:getProperty("advInfo"), | 202 | advInfo = self:getProperty("advInfo"), |
src/services/mcast_util.lua
@@ -92,18 +92,5 @@ function _M.pub_union(actionCode, bin) | @@ -92,18 +92,5 @@ function _M.pub_union(actionCode, bin) | ||
92 | chan_g:publish(actionCode, bin) | 92 | chan_g:publish(actionCode, bin) |
93 | end | 93 | end |
94 | 94 | ||
95 | -function _M.pub_person(fromFd, toRoleId, actionCode, bin) | ||
96 | - if 0 == redisproxy:exists(string.format("role:%d", toRoleId)) then | ||
97 | - return SYS_ERROR_CHAT_NOT_EXIST | ||
98 | - end | ||
99 | - -- 若在线,实时发送聊天信息 | ||
100 | - local agent = datacenter.get("agent", toRoleId) | ||
101 | - if agent then | ||
102 | - SendPacket(actionCode, bin, agent.fd) | ||
103 | - SendPacket(actionCode, bin, fromFd) | ||
104 | - return | ||
105 | - end | ||
106 | - return SYS_ERROR_CHAT_NOT_ONLINE | ||
107 | -end | ||
108 | 95 | ||
109 | return _M | 96 | return _M |
110 | \ No newline at end of file | 97 | \ No newline at end of file |