How does AMF communication work?

How does Flash interact with services / scripts on servers through AMF ?

As for the AMF libraries for Python / Perl / PHP, which are easier to develop than .NET / Java:

  • Do they execute script files when Flash sends a remote procedure call?
  • or do they interact through sockets, to script classes that work as services?

Regarding typical AMF features:

  • How is the data transmitted? are the method arguments that are automatically serialized?
  • How do servers push "clients" to do flash movies on a socket?

Thank you for your time.

+4
source share
2 answers

The only AMF library I am familiar with is PyAMF , which has been working well so far. Here are the answers to your questions for PyAMF:

  • I would suggest that you can run it as a script (do you mean CGI?), But the simplest IMO is to configure the application server specifically for AMF requests.

  • The easiest way is to define the functions in pure python that PyAMF wraps to serialize AMF inbound / outbound data.

  • you can communicate through sockets if this is what you need to do, but, again, it is easiest to use pure Python functions; one use for sockets is to maintain an open connection and push data to clients, see this example

Here is an example of three simple AMF services served on localhost:8080 :

 from wsgiref import simple_server from pyamf.remoting.gateway.wsgi import WSGIGateway ## amf services ################################################## def echo(data): return data def reverse(data): return data[::-1] def rot13(data): return data.encode('rot13') services = { 'myservice.echo': echo, 'myservice.reverse': reverse, 'myservice.rot13': rot13, } ## server ######################################################## def main(): app = WSGIGateway(services) simple_server.make_server('localhost', 8080, app).serve_forever() if __name__ == '__main__': main() 

I would definitely recommend PyAMF. Check out the examples to see what it is capable of and what the code looks like.

+8
source

How does Flash interact with services / scripts on servers through AMF?

Data is transmitted over a TCP / IP connection. Sometimes an existing HTTP connection is used, and in other cases, a new TCP / IP connection is opened for AMF data. When HTTP or additional TCP connections are open, the socket interface is probably used. AMF definitely travels over a TCP connection, and a socket interface is practically the only way to open such a connection.

The transmitted data consists of ECMA-script (Javascript (tm)) data types, such as "integer", "string", "object", etc.

For a technical specification of how objects are encoded into binary files, Adobe published the specification: AMF 3.0 Spec on Adobe.com

As a rule, the client / server AMF use system works, something like this:

  • The client displays some user interface and opens a TCP connection to the server.
  • The server sends some data to the client, which updates its user interface.
  • If the user makes a command, the client sends data to the server over a TCP connection.
  • Continue steps 2-3 until the user logs out.

For example, if the user clicks the send mail button in the user interface, then the client code can do this:

  public class UICommandMessage extends my.CmdMsg
 {
    public function UICommandMessage (action: String, arg: String)
    {
       this.cmd = action;
       this.data = String;
    }
 } 

Then later:

  UICommandMessage msg = new UICommandMessage ("Button_Press", "Send_Mail");
 server_connection.sendMessage (msg);

in the server code, the server also monitors the connection for the incoming AMF. It receives a message and transfers control to the corresponding response function. This is called sending a message.

With more information about what you are trying to accomplish, I could give you more useful details.

+4
source

All Articles