ee-protocol-json

0.1.0 • Public • Published

ee-protocol-json

simple JSON streaming protocol. transmitts & receives JSON objects.

build status

Build Status

installation

npm install ee-protocol-json

usage

on the receiving end of the line

var   JSONProtocolHandler 	= require( "ee-protocol-json" )
	, decoder 				= new JSONProtocolHandler()
	, incomingPacketData 	= new Buffer( [ 15, 0, 0, 0, 7b, 22, 66, 61, 62, 69, 61, 6e, 22, 3a, 22, 74, 68, 65, 20, 6b, 69, 6e, 67, 22, 7d ] );

decoder.wirte( incomingPacketData );

decoder.on( "data", function( JSONObject ){
	log( JSONObject ) // { fabian: "the king" }
} )

on the transmitting end of the line you must pass true to the contructor!

var   JSONProtocolHandler 	= require( "ee-protocol-json" )
	, encoder 				= new JSONProtocolHandler( true )
	, outgoingPacketData 	= new Buffer( { fabian: "the king" } );

encoder.wirte( outgoingPacketData );

instance.on( "data", function( data ){
	log( data ) // 15 0 0 0 7b 22 66 61 62 69 61 6e 22 3a 22 74 68 65 20 6b 69 6e 67 22 7d
} )

Readme

Keywords

none

Package Sidebar

Install

npm i ee-protocol-json

Weekly Downloads

1

Version

0.1.0

License

none

Last publish

Collaborators

  • ee