Get started

Simple socket client-server application

Server

1. Install amoeba and modules
npm install amoeba.io amoeba.io-local-client amoeba.io-socket-server
2. Create server.js
var Amoeba = require("amoeba.io");
var LocalClient = require("amoeba.io-local-client");
var SocketServer = require("amoeba.io-socket-server");

var amoeba = new Amoeba();
amoeba.path("chat").as(new LocalClient({
    test: function(param, callback) {
    	callback(null, "complete");
    }
}));
new SocketServer(amoeba, {
    port: "8090"
});
3. Run server
node server

Browser client

1. Download
bower install amoeba.io amoeba.io-socket-client
or
npm install amoeba.io amoeba.io-socket-client
2. Create index.html
<!DOCTYPE html>
<html>

<head>
    <title>Client</title>
    <script type="text/javascript" src="bower_components/amoeba.io/build/amoeba.io.min.js"></script>
    <script type="text/javascript" src="bower_components/amoeba.io-socket-client/build/amoeba.io-socket-client.min.js"></script>
    <script type="text/javascript">
    var amoeba = new Amoeba();
    amoeba.path("chat").as(new SocketClient({
        url: "http://localhost:8090"
    }), function(err) {
        if (!err) {
            //client connected
            amoeba.path("chat").invoke('test', { //call test
                hey: "test"
            }, function(err, result) { //get result
                console.log(result);
            });
        }
    });
    </script>
</head>

<body>

</body>

</html>
3. Open in browser