Name: telehash-mantle-js
Owner: telehash
Description: null
Created: 2016-06-16 19:14:17.0
Updated: 2017-09-30 21:59:46.0
Pushed: 2016-08-15 21:28:07.0
Homepage: null
Size: 62
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
telehash-mantle is a shared repository and cli tool for building a telehash sdk for node, electron, and cordova.
To leverage JavaScript code portability
Because Javascript code portability is a dirty lie.
install -g telehash-mantle
yproject
le -o ground.js --platform=<node/electron/cordova> --target=<version (electron only)> --format=<es/cjs> --transports=<serial-host,ble-central> --keystore=local
This will generate a ground.js
file that is tailored to your platform.
Usage is modeled after express. The flow is to initialize your app, configure middlewares, and turn it on
in.js
Ground = require("./ground.js");
app = Ground({/*options*/},function(err){
(err) console.log("error initializing telehash");
itelist connections
accept("asdf1234");
accept("mnbv9876");
acklist connections
reject("lkjhgfds");
syncronously accept connections
on('discover',function(greeting, accept){
omtUserToAcceptLink(greeting.json.hashname, function(){
link = accept();
//do stuff with link;
ndle new links
on('link', function(link){
send a console command to a link
nk.console("report()",function(err,result){
if (err) return console.log(err);
console.log(result);
create a generic channel, inherits from node streams
r chan = link.channel({json: {type : "event", label: "report"}, body: new Buffer("binary payload")});
data events;
an.on('data', function(packet){
console.log(packet.json, packet.body) // {stuff}, <Buffer >
pipe as stream
an.pipe(fs.createWriteStream("out.txt"));
send a one-off channel packet, no reply
nk.direct({type : "event", label:"stuff"}, new Buffer("payload"));
set an init script
nk.init(fs.readFileSync("path/to/script.js"), function(err, res){
terate through all open links
_links.forEach((link) => {
nk.console("parralel execution", ...)
se middlewares (coming soon)
mysql_sink = require("telehash-mysql-sink");
instance1 = mysql_sink({host: localhost...});
instance2 = mysql_sink({host : amazon...});
use(instance1);
use(instance2);
neric event middleware
events = require("filement-event");
use(events({label:"adfadf",callback: function(label, stuff){
StuffWithMatchingNetworkEvent(label, stuff)
art app
start()
listen();
- OR --
start(true);