我想让 AMF 请求正文与以下内容相同(查尔斯日志):
如 Charles 所示,它有一个“Command”值对象和一个“CCLocalPlayerChanges”值对象。我对此类对象的值感到困惑,如何使用 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'
或类映射:
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'
但他们都没有给我价值(如下所示,查尔斯的两个对象的价值都是空的):
我是 AMF 的新手,所以想知道对象值是否为空以及如何使用 RocketAMF gem 制作它们真的很重要。