Code Monkey home page Code Monkey logo

jarivs's Introduction

Meta.js 说明

Node-Parse说明

位置:libs/node-parse.js

使用:

const Node = require('../../libs/node-parse.js')
const meta = require('./meta.js') // 这里的meta是节点的元信息
var node = new Node(meta)

实例方法

Node.pub(topic, data)

发布一个广播消息,这个消息的主题不经过包装

topic:消息主题,比如node/msg

data:String类型的数据格式,如果要传输JSON格式的数据,先用JSON.stringify()方法转化

传输String类型数据

var node = new Node(meta)
node.pub('test_node/msg', 'hello world')

传输JSON类型数据

var node = new Node(meta)
node.pub('test_node/msg', JSON.stringify({"msg":"hello world"}))

Node.send(msg, data)

节点主动发送消息,这个消息包会经过包装,添加一个节点名称在最前面,节点名称在meta.json中定义 节点名称就是nodename字段变量

msg:发送的消息主题

data: 发送的数据,处理方法跟pub()相同

Node.usualPub(topic,data)

按照心跳频率广播消息 topic 消息主题 data 发送数据

var node = new Node(meta)
node.usualPub('cmd/foot/forward', null)
// 每0.1s发送数据包

Node.usualSend(topic, data)

按照在meta.js文件中定义的heartRate频率发送消息,作用和heart类似,避免重复定义心跳频率 使用方法和send类似,因为都是node主动发送的信息

jarivs's People

Contributors

aokihu avatar

Watchers

 avatar James Cloos 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.