使用Ruby RocketAMF组装AMF请求

时间:2013-04-08 21:05:17

标签: ruby amf

我想使AMF请求主体与以下相同(Charles log): enter image description here

如Charles所示,它具有“Command”值Object和“CCLocalPlayerChanges”值Object。我对这个对象的值感到困惑,如何使用RocketAMF制作它们?

我尝试过对这样的对象使用哈希:

data = [{
          :method => "load",
          :service => "start.game",
          :player_delta => {:stamina => 0},
          :sequence_num => self.sequence_num,
          :transaction_time => Time.now.to_i.to_s,
          :icp => 0,
        }]

env = RocketAMF::Envelope.new :amf_version => 3
env.messages << RocketAMF::Message.new('BatchController.authenticate_iphone', '/1', data)
body = env.to_s
res = RestClient.post "http://localhost/amf", env.to_s, :content_type => 'application/x-amf'

或ClassMapping:

class ClassCommand; attr_accessor :service, :sequence_num, :transaction_time, :icp; end;
command_obj = ClassCommand.new
command_obj.service = "start.game"
command_obj.sequence_num = 0
command_obj.transaction_time = Time.now.to_i.to_s
command_obj.icp = 0
RocketAMF::ClassMapper.define {|m| m.map :as => 'Command', :ruby => 'ClassCommand'}
data = [command_obj]

env = RocketAMF::Envelope.new :amf_version => 3
env.messages << RocketAMF::Message.new('BatchController.authenticate_iphone', '/1', data)
body = env.to_s
res = RestClient.post "http://localhost/amf", env.to_s, :content_type => 'application/x-amf'

但他们都没有给我价值(如下所示,这两个对象的价值都是空的):

enter image description here

我是AMF的新手,所以想知道对象值是否为空以及如何使用RocketAMF gem制作它们实际上很重要。

1 个答案:

答案 0 :(得分:0)

让您的生活更轻松的一个想法是只保存“查尔斯”请求,然后将File.read保存在红宝石中以便在帖子正文中使用。

相关问题