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

sy_node_rpc

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sy_node_rpc

一个node rpc框架

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

sy_node_rpc

一个node rpc框架

npm package

Getting Started

$ npm install sy_node_rpc --save

Server

const net = require('net');
const JSONSocket = require('sy_node_rpc').JSONSocket;

const server = net.createServer(function (socket) {
    socket = new JSONSocket({socket: socket});
    
    console.log('client connected', socket.remoteAddress);

    socket.addHandler('test.example', function (res) {
        console.log(res.body);
        res.send({words: 'world'});
    });

    socket.on('error', (err) => {
        console.error(err);
    });

    socket.on('close', () => {
        console.log('socket is close');
    });
});

server.on('error', (err) => {
    console.error(err);
});

server.listen(3101, () => {
    console.log('server bound');
});

Client

const JSONSocket = require('sy_node_rpc').JSONSocket;

const socket = new JSONSocket({host: 'localhost', port: 3101});

socket.on('connect', function () {
    console.log('client connected');
    socket.rpcRequest('test.example', {words: 'hello'}, function (err, body) {
        if (err) {
            return console.error(err);
        }
        console.log(body);
    });
});

socket.on('error', (err) => {
    console.error(err);
});

socket.on('close', () => {
    console.log('socket is close');
});

FAQs

Package last updated on 17 Jan 2018

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