New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

protomsg

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

protomsg

a little module to parse protocol messages over sockjs

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

protomsg

Build Status

a little module to parse protocol messages over sockjs. just npm install protomsg.

examples

Server:

var protomsg = require('protomsg');

// given a sockjs Connection object
var conn;

var emitter = protomsg(conn);
emitter.on("message:test", function (data, seq) {
	// data = "hi", seq = 1
});

// given a sockjs client connects and sends
var fakeMessage = JSON.stringify({id: "test", data: "hi", seq: 1});

// see listener body comment

Client:

var protomsg = require('protomsg');

var conn = new SockJS("//some/sock/server");

var emitter = protomsg(conn);

emitter.on("message:test", function (data, seq) {
	// data = "hi", seq = 1
});

// given the server we connected to sends
var fakeMessage = JSON.stringify({id: "test", data: "hi", seq: 1});

api

(sockServerOrClient)

given a sockjs serverside Connection object, or a sockjs client side SockJS object, emit events if messages using the following structure are found:

{
	id: String,
	data: Object,
	seq: Number
}

where the event name will be message:<id> for any id. Also emit malformed if a message is received that doesn't follow that structure.

events

malformed

occurs when a message doesn't follow the structure. argment is the raw data of the message.

message:id

occurs when a message is parsed properly, according to the structure. argument is the parsed Object, then the seq.

Keywords

protocol

FAQs

Package last updated on 25 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts