Blame view

robot/unitTest/chat.lua 866 Bytes
4dc77717   zhouhaihai   压测
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
  local MsgPack = MsgPack
  local skynet = require "skynet"
  
  
  local TIME_WAIT = 10 
  
  local _M = class("chat", require("unitTest.unitTest"))
  
  function _M:start()
  	self:task()
  end
  
  local taskMap = {
  	chat = {100},
  	searchFriend = {100},
  	friendList = {100},
  	friendRandom = {100},
  }
  
  function _M:task()
  	local curTask = math.randWeight(taskMap, 1)
  	self[curTask](self)
  	skynet.timeout(TIME_WAIT * 100, handler(self, self.task))
  end
  
  
  function _M:chat()
  	requestServer(actionCodes.Role_chatRpc, MsgPack.pack({ cmd = 1, content = "我就是个机器人, 我来测试测试没问题吧。"}))
  end
  
  function _M:searchFriend()
  	requestServer(actionCodes.Friend_searchRpc, MsgPack.pack({ key = "hehehe"}))
  end
  
  function _M:friendList()
  	requestServer(actionCodes.Friend_listRpc, '')
  end
  
  function _M:friendRandom()
  	requestServer(actionCodes.Friend_randomRpc, '')
  end
  
  return _M