Commit 073ba26524bc597bb388d96d07cf142bd36205b0
Merge branch 'develop' into tr/publish
* develop: 两个记录bug 新设备 遗失的log 充值返利邮件新增 调整压测 error 探索指令bug, 充值返利活动 挂机打完困难20101才设定完成引导22 挂机编队完成的时候服务器主动保存下一步引导,防止极端意外 探索指令调试完成
Showing
16 changed files
with
318 additions
and
46 deletions
Show diff stats
robot/robot.lua
... | ... | @@ -34,6 +34,9 @@ local ignoreListener = { |
34 | 34 | ["Role.changeUpdate"] = true, |
35 | 35 | ["Role.loadRunes"] = true, |
36 | 36 | ["Hero.loadInfos"] = true, |
37 | + ["Store.updateproperty"] = true, | |
38 | + ["Sys.maintainNotice"] = true, | |
39 | + ["Hero.drawHeroExtraRewardNtf"] = true, | |
37 | 40 | ["Sys.innerErrorMsg"] = function(data) |
38 | 41 | local msg = MsgPack.unpack(data) |
39 | 42 | log("innerErrorMsg: " .. msg.id) |
... | ... | @@ -123,11 +126,6 @@ local function startUnit(unit) |
123 | 126 | unitTest.new(client):startTest() |
124 | 127 | end |
125 | 128 | |
126 | -local function handle_timeout10000() | |
127 | - rpcServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "get", pm1 = 1, pm2 = 500})) | |
128 | - rpcServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "get", pm1 = 2, pm2 = 500})) | |
129 | - skynet.timeout(10000, handle_timeout6000) | |
130 | -end | |
131 | 129 | |
132 | 130 | -- 登录成功开始任务 |
133 | 131 | function CMD.task() |
... | ... | @@ -155,6 +153,9 @@ end |
155 | 153 | |
156 | 154 | -- 退出 |
157 | 155 | function CMD.exit() |
156 | + sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "gmmsg", pm1 = "123"})) | |
157 | + skynet.sleep(50) | |
158 | + skynet.ret(skynet.pack()) | |
158 | 159 | skynet.exit() |
159 | 160 | end |
160 | 161 | ... | ... |
robot/start.lua
... | ... | @@ -19,9 +19,9 @@ function MSG.open( ... ) |
19 | 19 | end |
20 | 20 | |
21 | 21 | function MSG.close(fd) |
22 | - if fd2serv[fd] then | |
23 | - skynet.send(fd2serv[fd].agent, "lua", "exit") | |
24 | - | |
22 | + if fd2serv[fd] and not fd2serv[fd].closing then | |
23 | + fd2serv[fd].closing = true | |
24 | + skynet.call(fd2serv[fd].agent, "lua", "exit") | |
25 | 25 | log(string_format("logout %s", fd2serv[fd].id)) |
26 | 26 | |
27 | 27 | id2fd[fd2serv[fd].id] = nil |
... | ... | @@ -94,8 +94,8 @@ local function add_robot() |
94 | 94 | |
95 | 95 | -- 定时下线 |
96 | 96 | skynet.timeout(math.randomInt(config.online_time[1], config.online_time[2]) * 100, function() |
97 | - socketdriver.close(fd) | |
98 | 97 | MSG.close(fd) |
98 | + socketdriver.close(fd) | |
99 | 99 | end) |
100 | 100 | end |
101 | 101 | ... | ... |
robot/unitTest/hero.lua
... | ... | @@ -26,7 +26,7 @@ end |
26 | 26 | |
27 | 27 | function _M:drawHero() |
28 | 28 | sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "get", pm1 = 3, pm2 = 400})) |
29 | - requestServer(actionCodes.Hero_drawHeroRpc, MsgPack.pack({pool = 1, type = 1})) | |
29 | + requestServer(actionCodes.Hero_drawHeroRpc, MsgPack.pack({pool = 2, type = 1})) | |
30 | 30 | end |
31 | 31 | |
32 | 32 | function _M:drawHero10() | ... | ... |
src/GlobalVar.lua
... | ... | @@ -293,8 +293,6 @@ MailId = { |
293 | 293 | SuperMonthCardEx = 204, |
294 | 294 | BattleCardAward = 210, |
295 | 295 | |
296 | - PaySignAward = 222, | |
297 | - | |
298 | 296 | ActSellFood = 231, |
299 | 297 | ActDrawCard = 232, |
300 | 298 | ActAdvDraw = 233, |
... | ... | @@ -303,6 +301,9 @@ MailId = { |
303 | 301 | ActDrawCardReward = 222, |
304 | 302 | ActAdvDrawReward = 223, |
305 | 303 | ActOpenBoxReward = 224, |
304 | + | |
305 | + PaySignAward = 241, | |
306 | + PayBackAward = 242, | |
306 | 307 | } |
307 | 308 | |
308 | 309 | TriggerEventType = { | ... | ... |
src/actions/GmAction.lua
... | ... | @@ -27,6 +27,7 @@ function _M.ignoreout(role, pms) |
27 | 27 | else -- 解除 |
28 | 28 | role:updateProperty({field = "ignoreMt", value = 0}) |
29 | 29 | end |
30 | + role:mylog("gm_action", {desc = "ignoreout", key1 = pms.sender}) | |
30 | 31 | return "指令生效" |
31 | 32 | end |
32 | 33 | |
... | ... | @@ -46,11 +47,17 @@ function _M.ban(role, pms) |
46 | 47 | end) |
47 | 48 | end |
48 | 49 | end |
50 | + | |
51 | + role:mylog("gm_action", {desc = "ban", int1 = time, int2 = ctype, key1 = pms.sender}) | |
52 | + | |
49 | 53 | return isBan and "解封杀成功" or "封杀成功" |
50 | 54 | end |
51 | 55 | |
52 | 56 | function _M.unban(role, pms) |
53 | 57 | role:setBan(0, 0) |
58 | + | |
59 | + role:mylog("gm_action", {desc = "unban", key1 = pms.sender}) | |
60 | + | |
54 | 61 | return "解封杀成功" |
55 | 62 | end |
56 | 63 | |
... | ... | @@ -63,6 +70,8 @@ function _M.gmmsg(role, pms) |
63 | 70 | skynet.call(agent.gate_serv, "lua", "forcekick", agent.fd) |
64 | 71 | end) |
65 | 72 | end |
73 | + role:mylog("gm_action", {desc = "gmmsg", text1 = pms.pm1, key1 = pms.sender}) | |
74 | + | |
66 | 75 | return "指令成功" |
67 | 76 | end |
68 | 77 | |
... | ... | @@ -73,6 +82,8 @@ function _M.silent(role, pms) |
73 | 82 | return "解禁言成功" |
74 | 83 | end |
75 | 84 | role:updateProperty({field = "silent", value = specTime({hour = 0}, skynet.timex()) + pm1 * 86400}) |
85 | + | |
86 | + role:mylog("gm_action", {desc = "silent", int1 = pms.pm1, key1 = pms.sender}) | |
76 | 87 | return "禁言成功" |
77 | 88 | end |
78 | 89 | |
... | ... | @@ -90,6 +101,8 @@ function _M.hero(role, pms) |
90 | 101 | if not role:addHero({type = heroType, log = {desc = "gm"}}) then |
91 | 102 | return "失败" |
92 | 103 | end |
104 | + | |
105 | + role:mylog("gm_action", {desc = "hero", int1 = heroType, key1 = pms.sender}) | |
93 | 106 | return "成功" |
94 | 107 | end |
95 | 108 | |
... | ... | @@ -122,6 +135,8 @@ function _M.herol(role, pms) |
122 | 135 | hero:updateProperty({field = "level", delta = addLevel}) |
123 | 136 | role:checkTaskEnter("HeroLevelUp", {level = hero:getProperty("level")}) |
124 | 137 | |
138 | + role:mylog("gm_action", {desc = "herol", int1 = heroType, int2 = addLevel, key1 = pms.sender}) | |
139 | + | |
125 | 140 | return "成功" |
126 | 141 | end |
127 | 142 | |
... | ... | @@ -133,6 +148,8 @@ function _M.herola(role, pms) |
133 | 148 | _M.herol(role, {pm1 = hero:getProperty("type"), pm2 = addLevel}) |
134 | 149 | end |
135 | 150 | |
151 | + role:mylog("gm_action", {desc = "herola", int1 = addLevel, key1 = pms.sender}) | |
152 | + | |
136 | 153 | return "成功" |
137 | 154 | end |
138 | 155 | |
... | ... | @@ -143,6 +160,7 @@ function _M.equip(role, pms) |
143 | 160 | local level = tonum(pms.pm2) |
144 | 161 | local count = tonum(pms.pm3) |
145 | 162 | role:addEquip(typ, level, count, {log = {desc = "gm"}}) |
163 | + role:mylog("gm_action", {desc = "equip", int1 = typ, int2 = level, long1 = count, key1 = pms.sender}) | |
146 | 164 | return "成功" |
147 | 165 | end |
148 | 166 | |
... | ... | @@ -151,6 +169,7 @@ function _M.rune(role, pms) |
151 | 169 | local typ = tonum(pms.pm1) |
152 | 170 | local id = tonum(pms.pm2) |
153 | 171 | local result = role:addRune({type = typ,id = id, log = {desc = "gm"}}) |
172 | + role:mylog("gm_action", {desc = "rune", int1 = typ, int2 = id, key1 = pms.sender}) | |
154 | 173 | |
155 | 174 | return result |
156 | 175 | end |
... | ... | @@ -171,6 +190,8 @@ function _M.fb(role, pms) -- 直接通关 |
171 | 190 | role:hangFinish(carbonId) |
172 | 191 | addPre(carbonId) |
173 | 192 | |
193 | + role:mylog("gm_action", {desc = "fb", int1 = carbonId, key1 = pms.sender}) | |
194 | + | |
174 | 195 | role:checkTaskEnter("HangPass", {id = carbonId}) |
175 | 196 | return "成功" |
176 | 197 | end |
... | ... | @@ -191,6 +212,8 @@ function _M.fbc(role, pms) -- 直接通关 |
191 | 212 | end |
192 | 213 | role:updateProperty({field = "hangPass", value = {}}) |
193 | 214 | addPre(carbonId) |
215 | + | |
216 | + role:mylog("gm_action", {desc = "fbc", int1 = carbonId, key1 = pms.sender}) | |
194 | 217 | |
195 | 218 | return "成功" |
196 | 219 | end |
... | ... | @@ -224,6 +247,8 @@ function _M.exp(role, pms) |
224 | 247 | exp = math.floor(math.max(exp, 0)) |
225 | 248 | role:addPlayExp(exp, {log = {desc = "gm"}}) |
226 | 249 | |
250 | + role:mylog("gm_action", {desc = "exp", int1 = exp, key1 = pms.sender}) | |
251 | + | |
227 | 252 | return "成功" |
228 | 253 | end |
229 | 254 | |
... | ... | @@ -280,6 +305,7 @@ function _M.get(role, pms) |
280 | 305 | end |
281 | 306 | local count = tonum(pms.pm2, 1) |
282 | 307 | role:award({[itemId] = count}, {log = {desc = "gm"}}) |
308 | + role:mylog("gm_action", {desc = "get", int1 = itemId, int2 = count, key1 = pms.sender}) | |
283 | 309 | end |
284 | 310 | return "成功" |
285 | 311 | end |
... | ... | @@ -303,6 +329,9 @@ function _M.advc(role, pms) |
303 | 329 | advAFWear = {}, |
304 | 330 | }, notNotify) |
305 | 331 | role.advData = nil |
332 | + | |
333 | + role:mylog("gm_action", {desc = "advc", key1 = pms.sender}) | |
334 | + | |
306 | 335 | return "成功" |
307 | 336 | end |
308 | 337 | |
... | ... | @@ -311,6 +340,8 @@ function _M.advf(role, pms) |
311 | 340 | role:updateProperty({field = "advC", value = 0}) |
312 | 341 | role.dailyData:updateProperty({field = "advElC", value = 0}) |
313 | 342 | |
343 | + role:mylog("gm_action", {desc = "advf", key1 = pms.sender}) | |
344 | + | |
314 | 345 | return "成功" |
315 | 346 | end |
316 | 347 | |
... | ... | @@ -330,6 +361,7 @@ function _M.adv(role, pms) |
330 | 361 | advPass[chapterId] = layer |
331 | 362 | role:updateProperty({field = "advPass", value = advPass}) |
332 | 363 | end |
364 | + role:mylog("gm_action", {desc = "adv", int1 = chapterId, int2 = layer, key1 = pms.sender}) | |
333 | 365 | |
334 | 366 | return "成功" |
335 | 367 | end |
... | ... | @@ -356,6 +388,7 @@ function _M.advt(role, pms) |
356 | 388 | isEnter = true, |
357 | 389 | debugMapId = mapId, |
358 | 390 | }) |
391 | + role:mylog("gm_action", {desc = "advt", int1 = chapterId, int2 = layer, key1 = pms.sender}) | |
359 | 392 | return "成功" |
360 | 393 | end |
361 | 394 | |
... | ... | @@ -364,6 +397,8 @@ function _M.advl(role, pms) |
364 | 397 | local exp = tonum(pms.pm1) |
365 | 398 | role:addAdvLvExp(math.max(0, exp)) |
366 | 399 | |
400 | + role:mylog("gm_action", {desc = "advl", int1 = exp, key1 = pms.sender}) | |
401 | + | |
367 | 402 | return "成功" |
368 | 403 | end |
369 | 404 | |
... | ... | @@ -377,6 +412,7 @@ function _M.advcl(role, pms) |
377 | 412 | end |
378 | 413 | advData.battle.player:addExp(exp) |
379 | 414 | advData:saveDB() |
415 | + role:mylog("gm_action", {desc = "advcl", int1 = exp, key1 = pms.sender}) | |
380 | 416 | |
381 | 417 | return "成功" |
382 | 418 | end |
... | ... | @@ -386,6 +422,7 @@ function _M.idlec(role, pms) |
386 | 422 | role:updateProperty({field = "hangTeam", value = {}}) |
387 | 423 | role:updateProperty({field = "hangInfo", value = {}}) |
388 | 424 | role:updateProperty({field = "hangBag", value = {}}) |
425 | + role:mylog("gm_action", {desc = "idlec", key1 = pms.sender}) | |
389 | 426 | |
390 | 427 | role.advData = nil |
391 | 428 | return "成功" |
... | ... | @@ -410,6 +447,8 @@ function _M.advit(role, pms) |
410 | 447 | local itemId = tonum(pms.pm1) |
411 | 448 | local count = tonum(pms.pm2) |
412 | 449 | reward[itemId] = count |
450 | + | |
451 | + role:mylog("gm_action", {desc = "advit", int1 = itemId, int2 = count, key1 = pms.sender}) | |
413 | 452 | end |
414 | 453 | |
415 | 454 | |
... | ... | @@ -425,6 +464,8 @@ function _M.tower(role, pms) |
425 | 464 | if not csvdb["tower_battleCsv"][level] then return "不存在" end |
426 | 465 | role:updateProperty({field = "towerInfo", value = {c = globalCsv.tower_count_limit, l = level}}) |
427 | 466 | |
467 | + role:mylog("gm_action", {desc = "tower", int1 = level, key1 = pms.sender}) | |
468 | + | |
428 | 469 | return "成功" |
429 | 470 | end |
430 | 471 | |
... | ... | @@ -443,6 +484,8 @@ function _M.email(role, pms) |
443 | 484 | rewardPms = id ~= 0 and reward or nil, |
444 | 485 | }) |
445 | 486 | |
487 | + role:mylog("gm_action", {desc = "email", int1 = id, key1 = pms.sender}) | |
488 | + | |
446 | 489 | return "成功" |
447 | 490 | end |
448 | 491 | |
... | ... | @@ -461,6 +504,8 @@ function _M.guide(role, pms) |
461 | 504 | end |
462 | 505 | end |
463 | 506 | role:updateProperty({field = "funcGuide", value = str}) |
507 | + role:mylog("gm_action", {desc = "sguide", key1 = pms.sender}) | |
508 | + | |
464 | 509 | elseif cmd == "RESET" then |
465 | 510 | local id = tonum(pms.pm2, 0) |
466 | 511 | if id == 0 then |
... | ... | @@ -473,6 +518,8 @@ function _M.guide(role, pms) |
473 | 518 | elseif id == 2 then |
474 | 519 | role:updateProperty({field = "funcGuide", value = ""}) |
475 | 520 | end |
521 | + role:mylog("gm_action", {desc = "cguide", int1 = id, key1 = pms.sender}) | |
522 | + | |
476 | 523 | end |
477 | 524 | |
478 | 525 | return "成功" |
... | ... | @@ -487,7 +534,7 @@ function _M.test(role, pms) |
487 | 534 | local id = tonum(pms.pm1, 0) |
488 | 535 | --local hero = require ("actions.HeroAction") |
489 | 536 | --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id})) |
490 | - print(role:getNextCarbonId(id)) | |
537 | + print(role:getPaybackReward(0, 10000)) | |
491 | 538 | return "成功" |
492 | 539 | end |
493 | 540 | ... | ... |
src/actions/HangAction.lua
... | ... | @@ -166,7 +166,7 @@ function _M.startRpc( agent, data ) |
166 | 166 | elseif carbonId == 10220 then |
167 | 167 | role:saveGuide(22,1) |
168 | 168 | end |
169 | - | |
169 | + role:mylog("hang_action", {desc = "startHang", int1 = carbonId}) | |
170 | 170 | SendPacket(actionCodes.Hang_startRpc, '') |
171 | 171 | return true |
172 | 172 | end |
... | ... | @@ -261,7 +261,7 @@ function _M.endBattleRpc(agent, data) |
261 | 261 | role:saveGuide(9, 2) |
262 | 262 | elseif carbonId == 10103 then |
263 | 263 | role:finishGuide(9) |
264 | - elseif carbonId == 10220 then | |
264 | + elseif carbonId == 20101 then | |
265 | 265 | role:finishGuide(22) |
266 | 266 | end |
267 | 267 | for _, guideData in pairs(csvdb["guide_unlockCsv"]) do |
... | ... | @@ -278,7 +278,6 @@ function _M.endBattleRpc(agent, data) |
278 | 278 | local cfg = csvdb["idle_battleCsv"][nextCarbonId] |
279 | 279 | if cfg then |
280 | 280 | hangInfo.bossTime = skynet.timex() + cfg.idle_time |
281 | - print(hangInfo.bossTime) | |
282 | 281 | end |
283 | 282 | end |
284 | 283 | role:updateProperty({field = "hangInfo", value = hangInfo}) |
... | ... | @@ -290,6 +289,9 @@ function _M.endBattleRpc(agent, data) |
290 | 289 | reward = reward, |
291 | 290 | }) |
292 | 291 | |
292 | + local team = role:getProperty("pvpTC") | |
293 | + role:mylog("hang_action", {desc = "hangBattle", short1 = msg.starNum > 0 and 1 or 0, int1 = carbonId, int2 = role:getProperty("hangTBV"), cint1 = role:getHerosCamp(team.heros)}) | |
294 | + | |
293 | 295 | SendPacket(actionCodes.Hang_endBattleRpc, MsgPack.pack({ |
294 | 296 | starNum = msg.starNum, |
295 | 297 | reward = reward, |
... | ... | @@ -332,6 +334,7 @@ function _M.roleFormatRpc(agent , data) |
332 | 334 | hangTeam.leader = msg.leader |
333 | 335 | hangTeam.supports = supports |
334 | 336 | role:saveHangTeam(hangTeam) |
337 | + role:saveGuide(5,8) | |
335 | 338 | SendPacket(actionCodes.Hang_roleFormatRpc, '') |
336 | 339 | return true |
337 | 340 | end |
... | ... | @@ -564,6 +567,8 @@ function _M.endBonusBattleRpc(agent, data) |
564 | 567 | info = msg.info, |
565 | 568 | reward = reward, |
566 | 569 | }) |
570 | + role:mylog("hang_action", {desc = "bonusBattle", short1 = msg.starNum > 0 and 1 or 0, int1 = id}) | |
571 | + | |
567 | 572 | SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({ |
568 | 573 | starNum = starNum, |
569 | 574 | reward = reward, |
... | ... | @@ -586,6 +591,7 @@ function _M.hangGiftRpc(agent, data) |
586 | 591 | local reward, change = role:award(carbonData.item_clear_special, {log = {desc = "hangGift", int1 = id}}) |
587 | 592 | |
588 | 593 | role:changeUpdates({{type = "hangGift", field = id, value = 1}}) |
594 | + role:mylog("hang_action", {desc = "hangGift", int1 = id}) | |
589 | 595 | |
590 | 596 | SendPacket(actionCodes.Hang_hangGiftRpc, MsgPack.pack({reward = reward, change = change})) |
591 | 597 | return true | ... | ... |
src/actions/RoleAction.lua
... | ... | @@ -292,7 +292,10 @@ function _M.loginRpc( agent, data ) |
292 | 292 | |
293 | 293 | local hangPass = role:getProperty("hangPass") |
294 | 294 | role:log("onLogin") |
295 | - | |
295 | + role:mylog("login", {key1 = agent.ip:toArray(false, ":")[1], int1 = hangPass[1] or 0}) | |
296 | + if msg.newdevice then | |
297 | + role:mylog("newdevice", {key1 = agent.ip:toArray(false, ":")[1]}) | |
298 | + end | |
296 | 299 | return true |
297 | 300 | end |
298 | 301 | |
... | ... | @@ -359,7 +362,10 @@ function _M.createRpc(agent, data) |
359 | 362 | newRole:log("onCreateAccount") |
360 | 363 | end |
361 | 364 | newRole:log("onCreateRole") |
362 | - | |
365 | + newRole:mylog("create", {key1 = agent.ip:toArray(false, ":")[1]}) | |
366 | + if msg.newdevice then | |
367 | + newRole:mylog("newdevice", {key1 = agent.ip:toArray(false, ":")[1]}) | |
368 | + end | |
363 | 369 | |
364 | 370 | SendPacket(actionCodes.Role_createRpc, MsgPack.pack(response)) |
365 | 371 | return true |
... | ... | @@ -552,7 +558,7 @@ function _M.openTimeBoxRpc(agent, data) |
552 | 558 | if boxL[slot].time > skynet.timex() then -- 没开完 |
553 | 559 | if not quick then return end |
554 | 560 | local cost_pre = globalCsv.box_timeOpen_diamond:toArray(true, "=") |
555 | - local costKey = math.ceil((boxL[slot].time - skynet.timex()) / (cost_pre[1] * 60)) * cost_pre[2] | |
561 | + costKey = math.ceil((boxL[slot].time - skynet.timex()) / (cost_pre[1] * 60)) * cost_pre[2] | |
556 | 562 | if not role:checkItemEnough({[ItemId.BoxKey] = costKey}) then return end |
557 | 563 | role:costItems({[ItemId.BoxKey] = costKey}, {log = {desc = "openTimeBox"}}) |
558 | 564 | end |
... | ... | @@ -687,8 +693,8 @@ function _M.storyBookRewardRpc(agent, data) |
687 | 693 | role:log("carriage_video", { |
688 | 694 | carriage_video_type = storyBookData.type, --放映室类型,剧情CG:0, 角色CG:1, 主线剧情:2, 角色剧情:3, 活动剧情:4, 图鉴:5 |
689 | 695 | carriage_video_id = storyId, --放映室片段ID |
690 | - carriage_video_coinid = reward[ItemId.Gold] and ItemId.Gold or 0, --放映奖励货币类型,无奖励则填写0 | |
691 | - carriage_video_coinnum = reward[ItemId.Gold] or 0, --放映奖励货币数量,无奖励则填写0 | |
696 | + carriage_video_coinid = reward[ItemId.Diamond] and ItemId.Diamond or 0, --放映奖励货币类型,无奖励则填写0 | |
697 | + carriage_video_coinnum = reward[ItemId.Diamond] or 0, --放映奖励货币数量,无奖励则填写0 | |
692 | 698 | carriage_video_item = reward, --放映奖励其他物品数量,json格式记录,{'itemid1':10,'itemid2':5,…………..},无奖励则填写0 |
693 | 699 | }) |
694 | 700 | |
... | ... | @@ -977,7 +983,7 @@ function _M.chatRpc(agent, data) |
977 | 983 | role:log("communication", { |
978 | 984 | publish_type = cmd, --发言类型,1,世界 2私聊 |
979 | 985 | publish_status = 0, --发送状态,发送成功:0,发送失败:1,被屏蔽:2,其他:3 |
980 | - publish_receive_roleid = msg.roleId, --接收者角色ID | |
986 | + publish_receive_roleid = msg.roleId or 0, --接收者角色ID | |
981 | 987 | publish_text = content, --发言内容 |
982 | 988 | }) |
983 | 989 | SendPacket(actionCodes.Role_chatRpc, MsgPack.pack({result = result, waitTime = waitTime})) |
... | ... | @@ -1007,7 +1013,7 @@ function _M.changeSettingRpc(agent, data) |
1007 | 1013 | local setting = role:getProperty("setting") |
1008 | 1014 | setting[id] = status |
1009 | 1015 | role:updateProperty({field = "setting", value = setting}) |
1010 | - | |
1016 | + role:mylog("role_action", {desc = "changeSetting", int1 = id, int2 = status}) | |
1011 | 1017 | SendPacket(actionCodes.Role_changeSettingRpc, '') |
1012 | 1018 | return true |
1013 | 1019 | end |
... | ... | @@ -1045,6 +1051,7 @@ function _M.drawCodeRpc(agent, data) |
1045 | 1051 | gift_name = "", -- 礼包名称 |
1046 | 1052 | gift_reason = 0, -- 礼包发放原因,见发放原因枚举表 |
1047 | 1053 | }) |
1054 | + role:mylog("role_action", {desc = "drawCode", int1 = giftId, key1 = code}) | |
1048 | 1055 | SendPacket(actionCodes.Role_drawCodeRpc, MsgPack.pack({ |
1049 | 1056 | result = ret, |
1050 | 1057 | reward = reward, |
... | ... | @@ -1119,6 +1126,7 @@ function _M.guideRpc(agent, data) |
1119 | 1126 | if msg.funcType then |
1120 | 1127 | funcGuide = funcGuide:setv(msg.funcType, 1) |
1121 | 1128 | role:log("onGuidePoint", {guild_type = 2, guild_id = msg.funcType, guild_point = 0, guild_pass = 0}) |
1129 | + role:mylog("guide", {desc = "guide_weak", int1 = msg.funcType}) | |
1122 | 1130 | end |
1123 | 1131 | role:updateProperty({field = "funcGuide", value = funcGuide}) |
1124 | 1132 | elseif cmdType == 3 then |
... | ... | @@ -1128,6 +1136,7 @@ function _M.guideRpc(agent, data) |
1128 | 1136 | funcGuide = funcGuide:setv(msg.funcType, 1) |
1129 | 1137 | role:updateProperty({field = "funcGuide", value = funcGuide}) |
1130 | 1138 | role:log("onGuidePoint", {guild_type = 1, guild_id = msg.funcType, guild_point = 0, guild_pass = 0}) |
1139 | + role:mylog("guide", {desc = "guide_sys", int1 = msg.funcType}) | |
1131 | 1140 | end |
1132 | 1141 | elseif cmdType == 4 then |
1133 | 1142 | -- 弹出一个tips(进入功能界面也许要自动弹说明,value要区分1、2) |
... | ... | @@ -1135,6 +1144,7 @@ function _M.guideRpc(agent, data) |
1135 | 1144 | local value = msg.value or 1 |
1136 | 1145 | for _, funcIdx in pairs(msg.funcType:toArray(true,"=")) do |
1137 | 1146 | role:log("onGuidePoint", {guild_type = 3, guild_id = funcIdx, guild_point = 0, guild_pass = 0}) |
1147 | + role:mylog("guide", {desc = "guide_tips", int1 = funcIdx}) | |
1138 | 1148 | funcGuide = funcGuide:setv(funcIdx, value) |
1139 | 1149 | end |
1140 | 1150 | role:updateProperty({field = "funcGuide", value = funcGuide}) |
... | ... | @@ -1211,20 +1221,18 @@ function _M.useSelectItemRpc(agent, data) |
1211 | 1221 | local role = agent.role |
1212 | 1222 | local msg = MsgPack.unpack(data) |
1213 | 1223 | local itemId = msg.itemId |
1214 | - local index = msg.index | |
1224 | + local subId = msg.subId | |
1215 | 1225 | local count = msg.count |
1216 | 1226 | if math.illegalNum(count, 1, role:getItemCount(itemId)) then return end |
1217 | 1227 | local itemData = csvdb["itemCsv"][itemId] |
1218 | 1228 | if itemData.type ~= ItemType.SelectItemBox then return end |
1219 | 1229 | local itemMap = itemData.use_effect:toNumMap() |
1220 | - local i = 1 | |
1221 | 1230 | local reward, change = {} |
1222 | 1231 | for k, v in pairs(itemMap) do |
1223 | - if i == index then | |
1232 | + if k == subId then | |
1224 | 1233 | reward[k] = v * count |
1225 | 1234 | break |
1226 | 1235 | end |
1227 | - i = i + 1 | |
1228 | 1236 | end |
1229 | 1237 | |
1230 | 1238 | if next(reward) then |
... | ... | @@ -1232,6 +1240,7 @@ function _M.useSelectItemRpc(agent, data) |
1232 | 1240 | role:costItems({[itemId] = count}, {log = {desc = "openItem"}}) |
1233 | 1241 | end |
1234 | 1242 | SendPacket(actionCodes.Role_useSelectItemRpc, MsgPack.pack(role:packReward(reward, change))) |
1243 | + return true | |
1235 | 1244 | end |
1236 | 1245 | |
1237 | 1246 | return _M |
1238 | 1247 | \ No newline at end of file | ... | ... |
src/actions/StoreAction.lua
... | ... | @@ -387,13 +387,13 @@ function _M.getExploreCommandRewardRpc(agent, data) |
387 | 387 | local subId = msg.subId -- 领取的阶段id |
388 | 388 | |
389 | 389 | local tab_name = "reward_levelpass" .. id .. "Csv" |
390 | - local config = csvdb[tab_name][id] | |
390 | + local config = csvdb[tab_name][subId] | |
391 | 391 | if not config then return end |
392 | 392 | |
393 | - local bpInfo = role.storeData:getProperty("bpInfo") or {} | |
393 | + local bpInfo = role.storeData:getProperty("bpInfo") or {} | |
394 | 394 | local info = bpInfo[id] or {} |
395 | 395 | local flag = info["flag"] or 0 |
396 | - if flag == 0 then return 1 end | |
396 | + --if flag == 0 then return 1 end | |
397 | 397 | |
398 | 398 | local freeRecord = info["fr"] or "" |
399 | 399 | local buyRecord = info["br"] or "" |
... | ... | @@ -418,7 +418,7 @@ function _M.getExploreCommandRewardRpc(agent, data) |
418 | 418 | if freeFlag == "0" then |
419 | 419 | gift = config.giftFree |
420 | 420 | |
421 | - freeRecord = string.setbit(freeRecord, id) | |
421 | + freeRecord = string.setbit(freeRecord, subId) | |
422 | 422 | info["fr"] = freeRecord |
423 | 423 | end |
424 | 424 | |
... | ... | @@ -428,11 +428,12 @@ function _M.getExploreCommandRewardRpc(agent, data) |
428 | 428 | end |
429 | 429 | gift = gift .. config.giftLimit |
430 | 430 | |
431 | - buyRecord = string.setbit(buyRecord, id) | |
431 | + buyRecord = string.setbit(buyRecord, subId) | |
432 | 432 | info["br"] = buyRecord |
433 | 433 | end |
434 | 434 | |
435 | - role.storeData:updateProperty({field = "bpInfo", value = info}) | |
435 | + bpInfo[id] = info | |
436 | + role.storeData:updateProperty({field = "bpInfo", value = bpInfo}) | |
436 | 437 | |
437 | 438 | local reward, _ = role:award(gift, {log = {desc = "exploreCommand", int1 = id, int2 = subId}}) |
438 | 439 | ... | ... |
src/models/Activity.lua
... | ... | @@ -9,6 +9,7 @@ Activity.ActivityType = { |
9 | 9 | AdvDraw = 5, --拾荒抽周 资助 |
10 | 10 | OpenBox = 6, --拆解周 时钟箱 |
11 | 11 | PaySignIn = 7, --付费签到 |
12 | + PayBack = 9, --返利 | |
12 | 13 | |
13 | 14 | SsrUpPoolChange = 10, -- 特定英雄活动,切卡池 |
14 | 15 | } |
... | ... | @@ -38,6 +39,7 @@ Activity.schema = { |
38 | 39 | act5 = {"table", {}}, -- {0 = 拆解数量, 1=1, 2=1} 拆解周活动 1表示领取过该档位的奖励 |
39 | 40 | act6 = {"table", {}}, -- {0 = 拾荒消耗远古金币数量, 1=1, 2=1} 拾荒周活动 1表示领取过该档位的奖励 |
40 | 41 | act7 = {"table", {}}, -- {1 = 1, 2 = 1} == 付费签到活动 |
42 | + act9 = {"number", 0}, -- 充值返利 | |
41 | 43 | } |
42 | 44 | |
43 | 45 | function Activity:data() |
... | ... | @@ -50,6 +52,7 @@ function Activity:data() |
50 | 52 | act5 = self:getProperty("act5"), |
51 | 53 | act6 = self:getProperty("act6"), |
52 | 54 | act7 = self:getProperty("act7"), |
55 | + act9 = self:getProperty("act9"), | |
53 | 56 | } |
54 | 57 | end |
55 | 58 | |
... | ... | @@ -324,6 +327,24 @@ activityFunc[Activity.ActivityType.PaySignIn] = { |
324 | 327 | -- end, |
325 | 328 | } |
326 | 329 | |
330 | +-- 充值反馈 | |
331 | +activityFunc[Activity.ActivityType.PayBack] = { | |
332 | + ["check"] = function(self, actType, notify, twd) -- 检查 | |
333 | + local oldVal = self:getActData(actType) or 0 | |
334 | + local newVal = oldVal + twd | |
335 | + local gift = self.owner:getPaybackReward(oldVal, newVal) | |
336 | + if gift ~= "" then | |
337 | + self.owner:sendMail(MailId.PayBackAward, nil, gift, {newVal}) | |
338 | + end | |
339 | + self:updateActData(actType, newVal, not notify) | |
340 | + end, | |
341 | + ["init"] = function(self, actType, isCrossDay, notify) | |
342 | + self:updateActData(actType, {}, not notify) | |
343 | + end, | |
344 | + -- ["close"] = function(self, actType, notify) | |
345 | + -- end, | |
346 | +} | |
347 | + | |
327 | 348 | function Activity:initActivity(actType, isCrossDay, notify) |
328 | 349 | if activityFunc[actType] and activityFunc[actType]['close'] then |
329 | 350 | activityFunc[actType]["init"](self, actType, isCrossDay, notify) | ... | ... |
src/models/Email.lua
... | ... | @@ -49,7 +49,7 @@ function Email:data() |
49 | 49 | if emailData then |
50 | 50 | -- 如果内容是直接插入到数据库 |
51 | 51 | if content == "" and emailData.body ~= "" then |
52 | - content = io.readfile("src/" .. emailData.body) | |
52 | + content = io.readfile("src/" .. emailData.body) or "" | |
53 | 53 | content = content:format(table.unpack(contentPms)) |
54 | 54 | end |
55 | 55 | ... | ... |
src/models/Role.lua
... | ... | @@ -149,6 +149,7 @@ Role.schema = { |
149 | 149 | battlePoint = {"number", 0}, -- 赛季卡使用的活跃点 |
150 | 150 | |
151 | 151 | rmbC = {"number", 0}, -- 人民币重置额 |
152 | + twdC = {"number", 0}, -- 台币总充值金额 | |
152 | 153 | |
153 | 154 | emailSync = {"number", 0}, -- 已经同步到的邮件Id |
154 | 155 | |
... | ... | @@ -373,6 +374,7 @@ function Role:data() |
373 | 374 | battlePoint = self:getProperty("battlePoint"), |
374 | 375 | |
375 | 376 | rmbC = self:getProperty("rmbC"), |
377 | + twdC = self:getProperty("twdC"), | |
376 | 378 | repayHero = self:getProperty("repayHero"), |
377 | 379 | newerDraw = self:getProperty("newerDraw"), |
378 | 380 | floorHero = self:getProperty("floorHero"), | ... | ... |
src/models/RolePlugin.lua
... | ... | @@ -238,7 +238,7 @@ function RolePlugin.bind(Role) |
238 | 238 | end |
239 | 239 | |
240 | 240 | if params.log then |
241 | - local log = params.log | |
241 | + local log = clone(params.log) | |
242 | 242 | if log["cint1"] or log["cint2"] then |
243 | 243 | print("addPlayExp error log have cint1 or cint2 or cint3", debug.traceback()) |
244 | 244 | end |
... | ... | @@ -275,7 +275,7 @@ function RolePlugin.bind(Role) |
275 | 275 | |
276 | 276 | self:logItems(params.itemId, origin, nums, params.log) |
277 | 277 | if params.log then |
278 | - local log = params.log | |
278 | + local log = clone(params.log) | |
279 | 279 | if log["cint1"] or log["cint2"] then |
280 | 280 | print("addItem error log have cint1 or cint2 ", debug.traceback()) |
281 | 281 | end |
... | ... | @@ -299,7 +299,7 @@ function RolePlugin.bind(Role) |
299 | 299 | function Role:checkItemEnough(itemCountT) |
300 | 300 | local less = {} |
301 | 301 | if not next(itemCountT) then |
302 | - return false, less | |
302 | + return true, less | |
303 | 303 | end |
304 | 304 | for itemId, count in pairs(itemCountT) do |
305 | 305 | if count <= 0 then |
... | ... | @@ -360,7 +360,7 @@ function RolePlugin.bind(Role) |
360 | 360 | |
361 | 361 | self:logItems(ItemId.Diamond, origin, count, params.log) |
362 | 362 | if params.log then |
363 | - local log = params.log | |
363 | + local log = clone(params.log) | |
364 | 364 | if log["cint1"] or log["cint2"] or log["cint3"] then |
365 | 365 | print("costDiamond error log have cint1 or cint2 or cint3 ", debug.traceback()) |
366 | 366 | end |
... | ... | @@ -410,7 +410,7 @@ function RolePlugin.bind(Role) |
410 | 410 | |
411 | 411 | self:logItems(ItemId.Diamond, origin, count, params.log) |
412 | 412 | if params.log then |
413 | - local log = params.log | |
413 | + local log = clone(params.log) | |
414 | 414 | if log["cint1"] or log["cint2"] or log["cint3"] then |
415 | 415 | print("costDiamond error log have cint1 or cint2 or cint3 ", debug.traceback()) |
416 | 416 | end |
... | ... | @@ -459,7 +459,7 @@ function RolePlugin.bind(Role) |
459 | 459 | self:logItems(heroType + ItemStartId.Hero, 0, 1, params.log) |
460 | 460 | |
461 | 461 | if params.log then |
462 | - local log = params.log | |
462 | + local log = clone(params.log) | |
463 | 463 | if log["cint1"] or log["cint2"] or log["cint3"] then |
464 | 464 | print("addHero error log have cint1 or cint2 or cint3 ", debug.traceback()) |
465 | 465 | end |
... | ... | @@ -580,7 +580,7 @@ function RolePlugin.bind(Role) |
580 | 580 | |
581 | 581 | self:logItems(equipCsv.id, oldCount, curCount, pms.log) |
582 | 582 | if pms.log then |
583 | - local log = pms.log | |
583 | + local log = clone(pms.log) | |
584 | 584 | if log["cint1"] or log["cint2"] or log["cint3"] then |
585 | 585 | print("addEquip error log have cint1 or cint2 or cint3 ", debug.traceback()) |
586 | 586 | end |
... | ... | @@ -656,7 +656,7 @@ function RolePlugin.bind(Role) |
656 | 656 | |
657 | 657 | self:logItems(params.id, 0, 1, params.log) |
658 | 658 | if params.log then |
659 | - local log = params.log | |
659 | + local log = clone(params.log) | |
660 | 660 | if log["cint1"] or log["cint2"] or log["cint3"] then |
661 | 661 | print("addRune error log have cint1 or cint2 or cint3 ", debug.traceback()) |
662 | 662 | end |
... | ... | @@ -686,7 +686,7 @@ function RolePlugin.bind(Role) |
686 | 686 | |
687 | 687 | self:logItems(rune:getProperty("id"), 1, 0, params.log) |
688 | 688 | if params.log then |
689 | - local log = params.log | |
689 | + local log = clone(params.log) | |
690 | 690 | if log["cint1"] or log["cint2"] or log["cint3"] then |
691 | 691 | print("delRunes error log have cint1 or cint2 or cint3 ", debug.traceback()) |
692 | 692 | end |
... | ... | @@ -946,7 +946,7 @@ function RolePlugin.bind(Role) |
946 | 946 | |
947 | 947 | self:logItems(func, 0, count, params.log) |
948 | 948 | if params.log then |
949 | - local log = params.log | |
949 | + local log = clone(params.log) | |
950 | 950 | if log["cint1"] or log["cint2"] or log["cint3"] then |
951 | 951 | print("funcOpen error log have cint1 or cint2 or cint3 ", debug.traceback()) |
952 | 952 | end |
... | ... | @@ -1586,10 +1586,13 @@ function RolePlugin.bind(Role) |
1586 | 1586 | reward[ItemId.Diamond] = (reward[ItemId.Diamond] or 0) + diamondCount |
1587 | 1587 | end |
1588 | 1588 | |
1589 | + self:checkTaskEnter("Pay", {rmb = rechargeData.rmb, twd = rechargeData.twd}) | |
1590 | + | |
1589 | 1591 | -- 累充 |
1590 | 1592 | local rmb = rechargeData.rmb |
1591 | 1593 | self:updateProperty({field = "rmbC", delta = rmb}) |
1592 | - | |
1594 | + self:updateProperty({field = "twdC", delta = rechargeData.twd}) | |
1595 | + | |
1593 | 1596 | self:mylog("role_action", {desc = "recharge", int1 = id, int2 = rmb, key1 = params.transactionId, key2 = params.order, long1 = params.pay_time}) |
1594 | 1597 | |
1595 | 1598 | return nil, reward |
... | ... | @@ -1695,6 +1698,37 @@ function RolePlugin.bind(Role) |
1695 | 1698 | return nextId |
1696 | 1699 | end |
1697 | 1700 | |
1701 | + -- 根据累计充值金额计算奖励档位 | |
1702 | + function Role:getPaybackReward(oldVal, newVal) | |
1703 | + local maxVal, diff, extraReward = 0, 0, "" | |
1704 | + local gift = "" | |
1705 | + for k, v in pairs(csvdb["rebateCsv"]) do | |
1706 | + if k > maxVal then | |
1707 | + maxVal = k | |
1708 | + end | |
1709 | + if v.isLoop > diff then | |
1710 | + diff = v.isLoop | |
1711 | + extraReward = v.reward | |
1712 | + end | |
1713 | + if oldVal < k and newVal > k then | |
1714 | + gift = gift .. v.reward .. " " | |
1715 | + end | |
1716 | + end | |
1717 | + if newVal > maxVal then | |
1718 | + local cnt = 0 | |
1719 | + if oldVal < maxVal then | |
1720 | + cnt = math.floor((newVal - maxVal) / diff) | |
1721 | + else | |
1722 | + cnt = math.floor((newVal - maxVal) / diff) - math.floor((oldVal - maxVal) / diff) | |
1723 | + end | |
1724 | + for i = 1, cnt do | |
1725 | + gift = gift .. extraReward .. " " | |
1726 | + end | |
1727 | + end | |
1728 | + | |
1729 | + return gift | |
1730 | + end | |
1731 | + | |
1698 | 1732 | end |
1699 | 1733 | |
1700 | 1734 | return RolePlugin |
1701 | 1735 | \ No newline at end of file | ... | ... |
src/models/RoleTask.lua
... | ... | @@ -89,6 +89,7 @@ local TaskType = { |
89 | 89 | WeBlog = 1010, -- 关注微博 |
90 | 90 | SignIn = 1011, -- 签到 |
91 | 91 | ShopAll = 1013, -- 在任意商店购买 |
92 | + Pay = 1014, -- 充值 | |
92 | 93 | } |
93 | 94 | |
94 | 95 | local function f(field, func) |
... | ... | @@ -216,6 +217,7 @@ local ActivityListener = { |
216 | 217 | [TaskType.FoodSell] = {{Activity.ActivityType.FoodSell, f("count")}}, |
217 | 218 | [TaskType.AdvDraw] = {{Activity.ActivityType.AdvDraw, f("count")}}, |
218 | 219 | [TaskType.OpenBox] = {{Activity.ActivityType.OpenBox, f("count")}}, |
220 | + [TaskType.Pay] = {{Activity.ActivityType.PayBack, f("twd")}}, | |
219 | 221 | } |
220 | 222 | } |
221 | 223 | ... | ... |
... | ... | @@ -0,0 +1,145 @@ |
1 | + | |
2 | +local skynet = require "skynet" | |
3 | +local socketdriver = require "skynet.socketdriver" | |
4 | +local serverId = tonumber(skynet.getenv("servId")) | |
5 | + | |
6 | +require "shared.init" | |
7 | +require "skynet.manager" | |
8 | + | |
9 | +local table_insert = table.insert | |
10 | +local pairs = pairs | |
11 | +local ipairs = ipairs | |
12 | +local string_format = string.format | |
13 | + | |
14 | +local logHandle = { | |
15 | + log = { | |
16 | + host = "127.0.0.1", | |
17 | + port = 13003, | |
18 | + handle = function(doc, address, msg) | |
19 | + -- 注入字段 | |
20 | + local now = skynet.timex() | |
21 | + doc["time"] = now | |
22 | + doc["timestamp"] = now | |
23 | + doc["instance_id"] = serverId | |
24 | + doc["game_name"] = "wasteland" | |
25 | + doc["env"] = "cb" | |
26 | + doc["app_name"] = "gs" | |
27 | + doc["app_id"] = "game.wasteland.gs" | |
28 | + --FATAL、ERROR、WARN、INFO、DEBUG | |
29 | + doc["level"] = "ERROR" | |
30 | + doc["log"] = msg | |
31 | + doc["address"] = string_format(":%08x", address) | |
32 | + end | |
33 | + }, | |
34 | +} | |
35 | + | |
36 | +local connect_relation = {} | |
37 | +local function getConInfo(fd) | |
38 | + return logHandle[connect_relation[fd] or ""] | |
39 | +end | |
40 | + | |
41 | + | |
42 | + | |
43 | +local socket_message = {} | |
44 | +-- read skynet_socket.h for these macro | |
45 | +-- SKYNET_SOCKET_TYPE_DATA = 1 | |
46 | +socket_message[1] = function(id, size, data) | |
47 | + skynet.error(string.format("LOG SOCKET: data: ", skynet.tostring(data, size))) | |
48 | + socketdriver.drop(data, size) | |
49 | +end | |
50 | + | |
51 | +-- SKYNET_SOCKET_TYPE_CONNECT = 2 | |
52 | +socket_message[2] = function(id, _ , addr) | |
53 | + local cur = getConInfo(id) | |
54 | + skynet.error("LOG SOCKET: connect: ", addr) | |
55 | + cur.connected = true | |
56 | + cur.connecting = false | |
57 | +end | |
58 | + | |
59 | +-- SKYNET_SOCKET_TYPE_CLOSE = 3 | |
60 | +socket_message[3] = function(id) | |
61 | + skynet.error("LOG SOCKET: closed") | |
62 | + local cur = getConInfo(id) | |
63 | + if not cur then return end | |
64 | + cur.connected = false | |
65 | + cur.connecting = false | |
66 | + connect_relation[id] = nil | |
67 | +end | |
68 | + | |
69 | +-- SKYNET_SOCKET_TYPE_ERROR = 5 | |
70 | +socket_message[5] = function(id, _, err) | |
71 | + skynet.error("LOG SOCKET: error: ", err) | |
72 | + local cur = getConInfo(id) | |
73 | + if not cur then return end | |
74 | + cur.connected = false | |
75 | + cur.connecting = false | |
76 | + connect_relation[id] = nil | |
77 | +end | |
78 | + | |
79 | + | |
80 | + | |
81 | +local function open() | |
82 | + for logTo, data in pairs(logHandle) do | |
83 | + if not data.connecting and not data.connected then | |
84 | + data.connecting = true | |
85 | + data.fd = socketdriver.connect(data.host, data.port) | |
86 | + connect_relation[data.fd] = logTo | |
87 | + end | |
88 | + end | |
89 | +end | |
90 | + | |
91 | +local function log(address, msg, logTo) | |
92 | + logTo = logTo or "log" | |
93 | + -- print(string.format(":%08x(%.2f): %s", address, skynet.time(), msg)) | |
94 | + local cur = logHandle[logTo] | |
95 | + if not cur then | |
96 | + print("error log to ", logTo) | |
97 | + end | |
98 | + local doc = {} | |
99 | + if cur.handle then | |
100 | + cur.handle(doc, address, msg) | |
101 | + end | |
102 | + if cur.connected and cur.fd then | |
103 | + socketdriver.send(cur.fd, json.encode(doc) .. "\n") | |
104 | + else | |
105 | + -- 断线会丢失一部分日志 | |
106 | + if not cur.connecting then | |
107 | + open() -- 连一下 | |
108 | + end | |
109 | + end | |
110 | +end | |
111 | + | |
112 | + | |
113 | +skynet.register_protocol { | |
114 | + name = "socket", | |
115 | + id = skynet.PTYPE_SOCKET, -- PTYPE_SOCKET = 6 | |
116 | + unpack = socketdriver.unpack, | |
117 | + dispatch = function (_, _, t, ...) | |
118 | + if socket_message[t] then | |
119 | + socket_message[t](...) | |
120 | + end | |
121 | + end | |
122 | +} | |
123 | + | |
124 | +-- register protocol text before skynet.start would be better. | |
125 | +skynet.register_protocol { | |
126 | + name = "text", | |
127 | + id = skynet.PTYPE_TEXT, | |
128 | + unpack = skynet.tostring, | |
129 | + dispatch = function(_, address, msg) | |
130 | + log(address, msg) | |
131 | + end | |
132 | +} | |
133 | + | |
134 | +skynet.register_protocol { | |
135 | + name = "SYSTEM", | |
136 | + id = skynet.PTYPE_SYSTEM, | |
137 | + unpack = function(...) return ... end, | |
138 | + dispatch = function() | |
139 | + -- reopen signal | |
140 | + print("SIGHUP") | |
141 | + end | |
142 | +} | |
143 | + | |
144 | +open() | |
145 | +skynet.start(function()end) | ... | ... |
src/services/redisd.lua
... | ... | @@ -24,5 +24,8 @@ skynet.start(function() |
24 | 24 | skynet.ret(skynet.pack(db[string.lower(cmd)](db, ...))) |
25 | 25 | end |
26 | 26 | end) |
27 | + skynet.info_func(function() | |
28 | + skynet.ret(skynet.pack(skynet.call(skynet.self(), "debug", "STAT"))) | |
29 | + end) | |
27 | 30 | skynet.register ".redis" |
28 | 31 | end) |
29 | 32 | \ No newline at end of file | ... | ... |