Code Monkey home page Code Monkey logo

amfjs's Introduction

amfjs

AMFJS is an AMF 3 Client JavaScript library

It is based on Surrey's R-AMF (AMF 99) implementation https://code.google.com/p/r-amf/

Why no AMF 0

The library does enough AMF 0 to be able to send message headers, anything more would only add weight.

Basic Example

Here is a AMFJS Ping Pong example:

<!doctype html>
<html>
<head>
	<title>AMFJS</title>
	<script src="amf.js" type="text/javascript"></script>
</head>
<body>
	<script type="text/javascript">
		amf.init("amfphp", "http://127.0.0.1/server/gateway.php");
        amf.invoke("test", "ping", [],
            function(data) {
                console.log(data);
            },
            function(data) {
                console.log("ping errror");
            }
        );
	</script>
</body>
</html>

This example loads an amf.js, which makes the amf global object available.

amf.init("amfphp", "http://127.0.0.1/server/gateway.php");

amf.init sets the destination and endpoint of the AMF Client.

amf.invoke("test", "ping", [],
    function(data) {
        console.log(data);
    },
    function(data) {
        console.log("ping errror");
    }
);

Sends and AMF request to the test service, invoking the ping method with no parameters. onResult and onStatus callback functions are also passed to the the invoke method.

The PHP service is very simple and looks like this.

<?php
class test
{
    public function ping()
	{
		return 'pong';
	}
}
?>

If the AMF Client has not been assigned a clientId by the server, a flex.messaging.messages.CommandMessage with a CLIENT_PING_OPERATION will be sent to the server first, in order to test connectivity over the current channel to the remote endpoint, and get a clientId assigned.

Framework Integration

  1. EnyoJs plugin

amfjs's People

Contributors

davidef avatar emilkm avatar

Stargazers

Joshua Weinberg avatar Yasuharu Hayami avatar

Watchers

 avatar Rochinsky avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.