The Morph Bridge application is meant to be an open source application that bridges communication over any and all (most) :D communication channels in existence.
The idea morphed from the bridge application that I developed on top. The bridge app bridged only websocket connections where as the morph bridge will be designed to bridge any communication protocol/channel available on nodejs. Currently only works if the protocols are being run from the same machine. Working out how to have remote networks communicate to each other. For more info, read the App Description and Design document up top.
- Edit the ip address in the test http.html webpage at lines 13 and 26. "nano tests/res/http.html"
- Run "npm install express" You are free to install the required modules for your node.
- Run "node tests/server.js &"
- Run "node test_http_node.js"
- On your browser go to the following address. "http://your_server_ip:800". When the page loads press "load messages". If a "No messages yet!" message appears then the node works. Correspondingly your terminal should notify you that "We got another one" .If not then shoot me an email. ^^.
- When running your nodes you can run it in the background. Will remove console.logging when the logging module is revamped
To use morphbridge the only two lines you need to learn how to use are:
I have also included some helper functions and objects to make it easier for people to use the module. The functions and objects are as follows:
</u>
Warning: Still under heavy development... Well the aim of the channels object was to allow for easy client. I had hope to implement methods such as client subscription, client removal, channel creation and deletion. This would allow you to register a client on a node to a certain channel and only have the client recieve messages from other channel clients. Clients would also be able to be removed from a channel when they close their connection or upon the evil wishes of the node master.. :D (thats you). However, as I developed this I realised that it was a bigger undertaking than I thought. I should actually develop it as a separate module.. In case there is a better substitute module, then don't require it. That said, I will give a basic rundown of the features I have implemented so far, or partially implemented.
Well.. using this function, a client of a node can directly control channel creation/destruction/and broadcasting. This feature was to allow a device to autonomously control which devices it is communicating with... giving more autonomy to the network of iot devices.
Warning: You have to create a logs folder in your base folder. Otherwise the nodes will not start.. working on a fix.. ㅠㅠ The logger object is a simple winston based logger that is intended to make Logging easy and non blocking. The efficiency of the logger is determined by the winston logging module hence is subject to changes that the maintainers of the module make. That said to make it easy, I have masked the internal function of the winston logger so that you only need to know two functions from the logger object. i.e.
This is a very simple buffer implementation that aims to accomodate non real time protocols/transports such as http post/get or sms. Be careful with the buffer as careless use can result in a runaway memory buildup. For the next morphbridge release I will set the preset limit of the buffer to 10 messages. However, if you would like to save more messages you can set the limit using the setLimit function I will list below. A fact worth noting, the buffer is emptied when a client queries for the stored messages. So it might not work if you have multiple asynchronous clients. It is a very basic buffer but it does its job well. That said, here are the functions exposed with the buffer object.