本文介绍了使用Ruby RocketAMF组合AMF请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使AMF请求正文与以下内容相同(查尔斯日志):


它具有一个 Command值对象和一个 CCLocalPlayerChanges值对象。我对此类对象的Value感到困惑,如何使用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',数据)
body = env.to_s
res = RestClient.post http:// localhost / amf,env。 to_s,:content_type => 'application / x-amf'

或ClassMapping:

 类ClassCommand; attr_accessor:service,:sequence_num,:transaction_time,:icp;结束; 
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’}
数据= [command_obj]

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

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





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

解决方案

让您的生活更轻松的一个想法是先保存查尔斯请求,然后保存 File.read 以红宝石的形式在邮件正文中使用。


I would like to make an AMF request body the same as the followings (Charles log):

As show in Charles, it has and a "Command" value Object and a "CCLocalPlayerChanges" value Object. I am confused with the Value for such object, how can I make them using RocketAMF?

I have tried using hash for such object:

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'

Or 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'

But neither of them gives me the Value (as can see below, both objects' value are empty from Charles):

I am new to AMF, so wondering does it actually matter if the object value is empty and how to make them with RocketAMF gem.

解决方案

One idea to make your life easier is to just save the 'charles' request, then File.read it in ruby to use in the post body.

这篇关于使用Ruby RocketAMF组合AMF请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 17:25