Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mar

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mar

MAR - Message & Reply, is a RPC library based on message exchange.

  • 0.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
decreased by-36.36%
Maintainers
1
Weekly downloads
 
Created
Source

MAR

MAR - Message & Reply - RPC library based on message exchange.

Quick Examples

Usage examples can be found here and below.

Server

var Server = require('mar').Server;

var s = new Server(8081);
s.on('ping', function(msg) {
  console.log('ping sent at [%s]', new Date(msg.data));
  if (msg.reply) msg.reply(null, new Date().getTime());
});

Client

var Client = require('mar').Client;

var c = new Client();
c.on('connect', function ping() {
  c.message('ping', new Date().getTime(), function(err, data) {
    if (err) return console.log(err);
    console.log('pong received at [%s]', new Date(data));
  });
});
c.connect({ host: 'localhost', port: 8081 });

Server - Authentication

var Server = require('mar').Server;

var s = new Server(8081);
s.on('ping', function(msg) {
  console.log('ping sent at [%s]', new Date(msg.data));
  if (msg.reply) msg.reply(null, new Date().getTime());
});

s.on('mar.auth', function(msg) {
  if (msg.data != 'foobar') return msg.reply('auth denied');
  msg.reply(null, 'auth granted');
});

Client - Authentication

var Client = require('mar').Client;

var c = new Client();
c.on('connect', function() {
  c.message('mar.auth', 'foobar', function(err, auth) {
    if (err) return console.log(err);
    console.log(auth);
    ping();
  });
});

function ping() {
  c.message('ping', new Date().getTime(), function(err, data) {
    if (err) return console.log(err);
    console.log('pong received at [%s]', new Date(data));
  });
}

c.connect({ host: 'localhost', port: 8081 });

Download

The source is available for download from GitHub. Alternatively, you can install using Node Package Manager (npm):

npm install mar

Future - TODO

There are many thoughts about future features for MAR library. You can find them here.

Keywords

FAQs

Package last updated on 27 Aug 2013

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc