Blame view

robot/unitTest/item.lua 1.23 KB
4dc77717   zhouhaihai   压测
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  local MsgPack = MsgPack
  local skynet = require "skynet"
  
  
  local TIME_WAIT = 10 
  
  local _M = class("item", require("unitTest.unitTest"))
  
  function _M:start()
  	self:task()
  end
  
  
  local taskMap = {
  	saleItem = {100},
  	openItem = {100},
3a646dea   zhouhaihai   拆分网关
17
  	-- openTimeBox = {100},
4dc77717   zhouhaihai   压测
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
  }
  
  function _M:task()
  	local curTask = math.randWeight(taskMap, 1)
  	self[curTask](self)
  	skynet.timeout(TIME_WAIT * 100, handler(self, self.task))
  end
  
  
  function _M:saleItem()
  	sendServer(actionCodes.Gm_clientRequest,  MsgPack.pack({cmd = "get", pm1 = 105, pm2 = 500}))
  	requestServer(actionCodes.Role_saleItemRpc, MsgPack.pack({backs = {[105] = 500}}))
  end
  
  
  function _M:openItem()
9fd2719f   zhouhaihai   物品
34
35
  	sendServer(actionCodes.Gm_clientRequest,  MsgPack.pack({cmd = "get", pm1 = 831, pm2 = 1}))
  	requestServer(actionCodes.Role_openItemRpc, MsgPack.pack({itemId = 831, count = 1}))
4dc77717   zhouhaihai   压测
36
37
38
39
40
41
42
43
44
45
46
  end
  
  function _M:openTimeBox()
  	sendServer(actionCodes.Gm_clientRequest,  MsgPack.pack({cmd = "get", pm1 = 6001, pm2 = 1}))
  	sendServer(actionCodes.Gm_clientRequest,  MsgPack.pack({cmd = "get", pm1 = 60, pm2 = 100}))
  	requestServer(actionCodes.Role_openTimeBoxRpc, MsgPack.pack({oper = 1, slot = 1, itemId = 6001}), function()
  		requestServer(actionCodes.Role_openTimeBoxRpc, MsgPack.pack({oper = 2, slot = 1, quick = 1}))
  	end)
  end
  
  return _M