Web 消息总线 JetBus

码农软件 · 软件分类 · ESB企业服务总线 · 2020-02-11 22:27:22

软件介绍

Jet 是一个用于 Web 的轻量级和实时的消息总线。支持浏览器和 Node.js node-jet,提供 Lua 版本 lua-jet 和基于 Arduino 的版本 Arduino-Jet

示例代码:

var jet = require('node-jet');

var peer = new jet.Peer({
  url: 'ws://jet.nodejitsu.com:80'
});

peer.connect().then(function() {
  console.log('peer is connected to daemon');
});

var machineName = new jet.State('machine/name', 'animal');
machineName.on('set', function(newName) {
  setMachineName(newName); // does something appropriate
});

peer.add(machineName).then(function() {
  console.log('machine/name has been added to daemon');
}).catch(function(err) {
  console.log('could not add machine/name to daemon', err);
});

// add a state
var cpuLoad = new jet.State('cpu/load', readCpuLoad());

peer.add(cpuLoad).then(function() {
  // async post new value
  setTimeout(function () {
    cpuLoad.value(readCpuLoad());
  },3000);
});

添加方法:

// add a method
var greet = new jet.Method('greet');
greet.on('call', function(name) {
    if (name.first === 'John') {
      throw 'John is a bad guy!';
    }
    var greeting = 'Hello ' + name.first + ' ' + name.last;
    console.log(greeting);
    return greeting;
});

peer.add(greet);


本文地址:https://codercto.com/soft/d/25414.html

Introduction to Algorithms, 3rd Edition

Introduction to Algorithms, 3rd Edition

Thomas H. Cormen、Charles E. Leiserson、Ronald L. Rivest、Clifford Stein / The MIT Press / 2009-7-31 / USD 94.00

Some books on algorithms are rigorous but incomplete; others cover masses of material but lack rigor. Introduction to Algorithms uniquely combines rigor and comprehensiveness. The book covers a broad ......一起来看看 《Introduction to Algorithms, 3rd Edition》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具