Module: McpackActionHelper

Defined in:
lib/action/module/mcpack_action.rb

Instance Method Summary collapse

Instance Method Details

#mcpack_send(headtype = HEADTYPE, version = VERSION, host = HOST, port = PORT, timeout = TIMEOUT, reserved1 = RESERVED1, reserved2 = RESERVED2, content) ⇒ Object

功能:

发送mcpack包

参数解释:

  • headtype 头类型目前支持: nshead shead

  • version mcpack的版本号

  • host 目的模块的ip

  • port 目的模块的端口

  • timeout 发送的超时时间

  • content mcapck包的文本

  • reserved1 保留字段1

  • reserved2 保留字段2

Example:

mcpack_send “nshead”, 1, “10.81.12.148”, 9109, 100, 1, 1, “{}”

检查的方法:

assert_head “正则式” assert_body “正则式” mcpack_send “{}”



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/action/module/mcpack_action.rb', line 27

def mcpack_send(headtype=HEADTYPE, version=VERSION, host=HOST, port=PORT, timeout=TIMEOUT, reserved1=RESERVED1, reserved2=RESERVED2, content)
  toolspath = TOOL_ROOT+"/mcsend/"
  if(headtype=="nshead")
    cmdtxt="cd #{toolspath}; ./mcsend2 #{version} #{host} #{port} #{timeout} \"#{content}\" #{reserved1}"
    ret=`#{cmdtxt}`
    ary=ret.split "\n"
    Context.set("IOHEAD", ary[0])
    Context.set("IOBODY", ary[1])
  elsif(headtype=="shead")
    cmdtxt="cd #{toolspath}; ./mcsend2_shead #{version} #{host} #{port} #{timeout} \"#{content}\" #{reserved1} #{reserved2}"
    ret=`#{cmdtxt}`
    ary=ret.split "\n"
    Context.set("IOHEAD", ary[0])
    Context.set("IOBODY", ary[1])
  else
    puts "Not support headtype: #{headtype} yet"
  end
  #puts cmdtxt
  $log.debug cmdtxt  
  $log.debug Context.get("IOHEAD")
  $log.debug Context.get("IOBODY")
end