0.0.17 • Published 5 years ago

mtm-ws-router v0.0.17

Weekly downloads
25
License
LGPL-3.0
Repository
-
Last release
5 years ago

MtmWsRouter

MtmWsRouter is a java script version of the client lib for the php package MTM/WsRouter ()

For node.js, you can use this command to install:

npm install mtm-ws-router

import the service:

import { MtmWsRouter } from "mtm-ws-router";

USE assuming you have injected the service using the _mtmWsRouter variable name:

	var ssl	= true;
	var id		= "myClientName";
	var ip		= "127.0.0.1";
	var port	= 6653;

	var authData	= {"mySecret": "qefuiu&^%$##seeture"}; //authenticate with the border gateway
	var bcObj		= this._mtmWsRouter.getNodes().getBorderClient(id, ip, port).setSsl(ssl);
	
	//specify the function that should handle ingress messages takes a single argument
	bcObj.setIngressCb(this, "ingressHandler");
	
	bcObj.connect(authData).then((rObj)=>{
		
		var peerObj	= bcObj.getPeersById("somePeerId");
		if (peerObj !== null) {
			
			//send a message to the peer and wait for its response
			//data can be anything that is supported by json.stringify
			//default timeout is 10000ms
			var msgObj		= {"type": "message", "data": "Hello peer"};
			peerObj.newRequest(msgObj).get().then((data)=>{
				console.log(data); //return data
			});
			
		} else {
			console.log("Missing Peer");
			reject("Missing Peer");
		}

	}, (errObj)=>{
		console.log("Connect failed");
		console.log(errObj);
	});
	
0.0.17

5 years ago

0.0.16

5 years ago

0.0.15

5 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago