wsl-messenger

0.1.4 • Public • Published

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)    
})

Readme

Keywords

none

Package Sidebar

Install

npm i wsl-messenger

Weekly Downloads

1

Version

0.1.4

License

BSD-3-Clause

Last publish

Collaborators

  • mlaszczewski