8.0.16 • Published 6 years ago

muonjs v8.0.16

Weekly downloads
4
License
Apache2
Repository
github
Last release
6 years ago

Muon JS

Muon in the browser.

See http://muoncore.io for more information on muon

Getting Started

To test drive muon.js, you can run the demo application. This starts a gateway, and demonstrates the capabilities coming from running muon in the browser.

Dependencies

You'll need two dependencies:

npm install
make
make run

Visit http://localhost:5000 for a running muon instance in the browser. It is given full permissions to communicate with the local muon environment.

Start a few other muon services, especially event services, such as Photon.

Adding to your application

You will need to implement both a server side gateway, and a client browser application.

Gateway

A websocket based transport message router is required for muon instances in the browser to connect to.

A prebuilt gateway is available at https://github.com/muoncore/muonjs-gateway.js, and this is recommended for use.

Building Your own Gateway

This is an advanced task, for very tight control of the message flows from browser to server side.

See the existing gateway. The only currently supported server side setup is node.js with Express.

var http = require("http")
var express = require("express")
var app = express()
var port = process.env.PORT || 5000
app.use(express.static("./test/server"))
var server = http.createServer(app)
server.listen(port)

var Muon = require("muon-core"); // <1>

var muon = Muon.create("browser-gateway", process.env.MUON_URL || "amqp://muon:microservices@localhost"); // <2>
var muonjs = require("muon.js").gateway(server, muon) // <3>

<1> Import Muon Core. <2> Create a new Muon service, the local gateway. This will be used to communicate with the rest of the system <3> Create a Muon.js browser gateway. Muon browser clients will communicate with this.

That's it!

Client

Muon.js is published to NPM. Include it into your application using require and use a packager, such as browserify or webpack to transpile it into your application code.

Here is a minimal browser javascript script.

This instantiates a muon instance, which will connect to the gateway you created above.

var muon = require("muon.js").client()  // <1>

setInterval(function(){
    var then = new Date().getTime();
    muon.request("rpc://myservice/endpoint", {"message": "BE AWESOME"}, function(resp) {  <2>
        var now = new Date().getTime();
        logger.info("Latency = " + (now - then))
        console.dir(resp)   //<3>
    });
}, 2000)

<1> Instantiate a muon.js client. This auto connects to the gateway using websockets. <2> Every two seconds, make an rpc request to myservice <3> Process the response, logging it to the browser javascript console.

You will need to process this into something you can import, using browserify or webpack.

8.0.17-0

6 years ago

8.0.16

6 years ago

8.0.15

6 years ago

8.0.14

6 years ago

8.0.13

6 years ago

8.0.12

6 years ago

8.0.11

6 years ago

8.0.10

6 years ago

8.0.9

6 years ago

8.0.8

6 years ago

8.0.7

6 years ago

8.0.6

6 years ago

8.0.5

6 years ago

8.0.4

6 years ago

8.0.3

6 years ago

8.0.2

6 years ago

8.0.1

6 years ago

8.0.0

6 years ago

7.3.0-83

6 years ago

7.3.0-82

6 years ago

7.3.0-81

6 years ago

7.3.0-80

6 years ago

7.3.0-79

6 years ago

7.3.1

6 years ago

7.3.0-78

7 years ago

7.3.0-77

7 years ago

7.3.0-76

7 years ago

7.2.6

7 years ago

7.1.23

7 years ago

7.1.16

7 years ago

7.1.10

7 years ago

7.1.9

7 years ago

7.1.7

8 years ago

7.1.6

8 years ago

7.1.5

8 years ago

7.1.2

8 years ago

7.1.1

8 years ago

7.1.0

8 years ago

0.0.55

8 years ago

0.0.54

8 years ago

0.0.53

8 years ago

0.0.52

8 years ago

0.0.51

8 years ago

0.0.50

8 years ago

0.0.49

8 years ago

0.0.44

8 years ago

0.0.43

8 years ago

0.0.40

8 years ago

0.0.39

8 years ago

0.0.38

8 years ago

0.0.37

8 years ago

0.0.33

8 years ago

0.0.32

8 years ago

0.0.31

8 years ago

0.0.24

8 years ago

0.0.23

8 years ago

0.0.22

8 years ago

0.0.21

8 years ago

0.0.20

8 years ago

0.0.19

8 years ago

0.0.18

8 years ago

0.0.17

8 years ago

0.0.16

8 years ago

0.0.15

8 years ago

0.0.14

8 years ago

0.0.13

8 years ago

0.0.12

8 years ago

0.0.11

8 years ago

0.0.10

8 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago