README
Weasel messaging
Simple messaging library
UDP
var socket = require('dgram').createSocket('udp4')
socket.bind()
var frameSize=512
var wslMessenger = require('wsl-messenger')
var messenger=wslMessenger.createDgramMessenger(socket,wslMessenger.jsonEncoder,wslMessenger.jsonDecoder,frameSize,'127.0.0.1',2323)
messenger.send({
type:'welcome'
})
messenger.on('message',function(msg){
console.log('Received',msg)
})
TCP or system socket
var socket=require('net').connect({host:'localhost', port:23231})
var wslMessenger = require('wsl-messenger')
var messenger=wslMessenger.createStreamMessenger(socket,wslMessenger.jsonEncoder,wslMessenger.jsonDecoder)
messenger.send({
type:'welcome'
})
messenger.on('message',function(msg){
console.log('Received',msg)
})