messagingjs
v1.0.0
Published
Communicate between node.js apps
Downloads
3
Maintainers
Readme
messaging
Server:
var fs = require("fs");
var messaging = require("messagingjs");
var port = 8888;
messaging.Server(port,function(client){
client.onMessage("hello",function(obj){
console.log("Client name is: "+obj.name);
client.sendMessage("hello",{name: "Server"});
});
client.onBinary("file",function(buff){
fs.writeFile("filename",buff);
});
});
Client:
var fs = require("fs");
var messaging = require("messagingjs");
var serverIP = "127.0.0.1"
var port = 8888;
var client = new messaging.Client(serverIP,port);
client.onMessage("hello",function(obj){
if(obj.name == "Server"){
fs.readFile("filename",function(err,buff){
client.sendBinary("file",buff);
});
}
});
client.sendMessage("hello",{name: "Giancarlo"});