How to deserialize and serialize AMF Packets in Python?

1.4k Views Asked by At

I am rewriting the following Perl code in Python:

  my $data = Data::AMF::Packet->new->deserialize($packet);
  $data->messages->[0]->{value}->[1] = $data->messages->[1]->{value}->[1] = $mid;
  $data = $data->serialize;

I would like to know how to write this in Python? I am new to PyAMF and the examples I googled wont help.

Thanks a lot!

1

There are 1 best solutions below

0
njoyce On

Something along the lines of:

from pyamf import remoting

packet = remoting.decode(bytes)
packet['/1'][1] = packet['/2'][1]

stream = remoting.encode(packet)

bytes = stream.getvalue()