Note that there are some explanatory texts on larger screens.

plurals
  1. POAssemble AMF request with Ruby RocketAMF
    text
    copied!<p>I would like to make an AMF request body the same as the followings (Charles log): <img src="https://i.stack.imgur.com/0gDiu.png" alt="enter image description here"></p> <p>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?</p> <p>I have tried using hash for such object:</p> <pre><code>data = [{ :method =&gt; "load", :service =&gt; "start.game", :player_delta =&gt; {:stamina =&gt; 0}, :sequence_num =&gt; self.sequence_num, :transaction_time =&gt; Time.now.to_i.to_s, :icp =&gt; 0, }] env = RocketAMF::Envelope.new :amf_version =&gt; 3 env.messages &lt;&lt; RocketAMF::Message.new('BatchController.authenticate_iphone', '/1', data) body = env.to_s res = RestClient.post "http://localhost/amf", env.to_s, :content_type =&gt; 'application/x-amf' </code></pre> <p>Or ClassMapping:</p> <pre><code>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 =&gt; 'Command', :ruby =&gt; 'ClassCommand'} data = [command_obj] env = RocketAMF::Envelope.new :amf_version =&gt; 3 env.messages &lt;&lt; RocketAMF::Message.new('BatchController.authenticate_iphone', '/1', data) body = env.to_s res = RestClient.post "http://localhost/amf", env.to_s, :content_type =&gt; 'application/x-amf' </code></pre> <p>But neither of them gives me the Value (as can see below, both objects' value are empty from Charles):</p> <p><img src="https://i.stack.imgur.com/ZuIa6.png" alt="enter image description here"></p> <p>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.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload