2.1.2 • Published 2 years ago

motebus v2.1.2

Weekly downloads
35
License
ISC
Repository
github
Last release
2 years ago

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 
2.1.2

2 years ago

2.1.1

2 years ago

2.1.0

3 years ago

2.0.9

3 years ago

2.0.8

3 years ago

2.0.7

4 years ago

2.0.5

4 years ago

2.0.6

4 years ago

2.0.4

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.1.0

5 years ago

1.0.9

5 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago