# motebus

> MoteBus SDK for node.js

Latest version **2.1.2** (published 2022-02-22) · ISC license · 0 weekly downloads

## Install

```sh
npm install motebus
pnpm add motebus
yarn add motebus
bun add motebus
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.1.2 |
| Published | 2022-02-22 |
| First published | 2017-10-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 25.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 125 |
| Author | Richard Ho |
| Maintainers | motebus |
| Keywords | MoteBus |

## Links

- npm: https://www.npmjs.com/package/motebus
- Repository: https://github.com/motebus/motebus
- Issues: https://github.com/motebus/motebus/issues
- npm.io page: https://npm.io/package/motebus

## Recent versions

- 2.1.2 (latest) — 2022-02-22
- 2.1.1 — 2022-02-18
- 2.1.0 — 2021-09-03
- 2.0.9 — 2021-06-30
- 2.0.8 — 2021-05-24
- 2.0.7 — 2020-08-24
- 2.0.6 — 2020-07-31
- 2.0.5 — 2020-07-31
- 2.0.4 — 2020-06-18
- 2.0.3 — 2020-03-27
- 2.0.2 — 2020-03-20
- 2.0.1 — 2020-03-11
- 2.0.0 — 2019-11-20
- 1.1.0 — 2019-06-18
- 1.0.9 — 2018-12-12
- … 8 more at https://npm.io/package/motebus/versions

## README

# motebus

MoteBus is a message transport bus for peer-to-peer communication. It supports xMsg, xRPC protocols.

To use this package, it is necessary to acquire the motebus binary file from https://github.com/motebus/motebus/releases


### Install 

    npm install motebus
    
### Usage

Add the motebus module to the code
    
    motebus = require('motebus');
   
The module mainly contains two classes: xRPC and xMsg

### xRPC   
    xrpc = motebus.xRPC();

xRPC contains two functions

The publish function will publish the app which contains your functions on the motebus network. 
    
    xrpc.publish("APPNAME","MODULE");
        "APPNAME"             expects a string of the appname being defined in your program
        "MODULE"              expects a string of the function defined inside the appname, multi functions are possible.

The call function will call the function that has been published 
    
    xrpc.call("TARGET","FUNCTION","ARGUMENTS","PRIO","TIMEOUT1","TIMEOUT2");
        "TARGET"              expects a string of MMA, which contains "APPNAME"@"IP"
        "FUNCTION"            expects a string as the function name in App
        "ARGUMENT"            expects a list in dictionary format such as {"A":"12","B":"25"}
        "PRIO"                expects an Integer to indicate the priority of the request
        "TIMEOUT1"            expects an Integer to indicate the maximum sending time
        "TIMEOUT2"            expects an Integer to indicate the maximum reply waiting time
   
### xMsg
    xmsg = motebus.xMsg();
xMsg contains 4 functions

The open function sets the current user as available

    xmsg.open("ALIAS","PASSWORD","UNIQUE","CALLBACK");
        "ALIAS"               expects a string of the ID published on the network
        "PASSWORD"            expects a password string, can be left blank
        "UNIQUE"              expects a string of "true" or "false", permission for duplicated ALIAS ID 
        "CALLBACK"            expects a defined function for callback action 
        
The send function sends the message to the previously defined target

    xmsg.send("TARGET","BODY","FILES","PRIO","TIMEOUT1","TIMEOUT2","CALLBACK");
        "TARGET"              expects a string of MMA, which contains "APPNAME"@"IP"
        "BODY"                expects a string of the message
        "FILES"               expects a string of the file path
        "PRIO"                expects an Integer to indicate the priority of the request
        "TIMEOUT1"            expects an Integer to indicate the maximum sending time
        "TIMEOUT2"            expects an Integer to indicate the maximum reply waiting time
        "CALLBACK"            expects a defined function for callback action 
        
The reply function is used to reply to the received message

    xmsg.reply("HEAD","BODY","FILES","PRIO","TIMEOUT1","TIMEOUT2","CALLBACK");
        "HEAD"                expects a string of MMA, which contains "APPNAME"@"IP"
        "BODY"                expects a string of the message
        "FILES"               expects a string of the file path
        "PRIO"                expects an Integer to indicate the priority of request
        "TIMEOUT1"            expects an Integer to indicate the maximum sending time
        "TIMEOUT2"            expects an Integer to indicate the maximum reply waiting time
        "CALLBACK"            expects a defined function for callback action 

The extract function is for saving the file received to the PATH you defined. 
    
    xmsg.extract("MESSAGE_ID","PATH","CALLBACK");
        "MESSAGE_ID"          expects a string of the senders DDN
        "PATH"                expects a string of the stored file path
        "CALLBACK"            expects a defined function for callback action

---
_Source: https://npm.io/package/motebus · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
