npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hprose

v2.0.51

Published

hprose for node.js

Downloads

154

Readme

Hprose for Node.js

Join the chat at https://gitter.im/hprose/hprose-nodejs npm download optionalDependency Status npm version License



Introduction

Hprose is a High Performance Remote Object Service Engine.

It is a modern, lightweight, cross-language, cross-platform, object-oriented, high performance, remote dynamic communication middleware. It is not only easy to use, but powerful. You just need a little time to learn, then you can use it to easily construct cross language cross platform distributed application system.

Hprose supports many programming languages, for example:

  • AAuto Quicker
  • ActionScript
  • ASP
  • C++
  • Dart
  • Delphi/Free Pascal
  • dotNET(C#, Visual Basic...)
  • Golang
  • Java
  • JavaScript
  • Node.js
  • Objective-C
  • Perl
  • PHP
  • Python
  • Ruby
  • ...

Through Hprose, You can conveniently and efficiently intercommunicate between those programming languages.

This project is the implementation of Hprose for Node.js.

Hprose 2.0 for Node.js Documents(中文版): https://github.com/hprose/hprose-nodejs/wiki

Usage

Http Server

Synchronous Functions or Methods

Hprose for Node.js is very easy to use. You can create a hprose server like this:

var hprose = require("hprose");
function hello(name) {
    return "Hello " + name + "!";
}
var server = hprose.Server.create("http://0.0.0.0:8080");
server.addFunction(hello);
server.start();

To start it use:

node --harmony server.js

--harmony is a v8 options, hprose use it to optimize serialization. This is not required option, but it is recommended to use it.

Asynchronous Functions or Methods

In fact most nodejs service methods are asynchronous, you can publish asynchronous function like this:

var hprose = require("hprose");
function hello(name, callback) {
    setTimeout(function() {
        callback("Hello " + name + "!");
    }, 10);
}
var server = hprose.Server.create("http://0.0.0.0:8080");
server.addAsyncFunction(hello);
server.start();

Http Client

Then you can create a hprose client to invoke it like this:

var hprose = require("hprose");
var client = hprose.Client.create("http://127.0.0.1:8080/");
var proxy = client.useService();
proxy.hello("world", function(result) {
    console.log(result);
});

To start it use:

node --harmony client.js

or

node --harmony-proxies client.js

Without --harmony-proxies, you need create proxy like this:

var hprose = require("hprose");
var client = hprose.Client.create("http://127.0.0.1:8080/");
var proxy = client.useService(["hello"]);
proxy.hello("world", function(result) {
    console.log(result);
});

Or create client like this:

var hprose = require("hprose");
var client = hprose.Client.create("http://127.0.0.1:8080/", ["hello"]);
client.hello("world", function(result) {
    console.log(result);
});

Exception Handling

If an error occurred on the server, or your service function/method throw an exception, it will be sent to the client. You need to pass an error callback function after succuss callback function to receive it. If you omit this callback function, the client will ignore the exception, like never happened.

For example:

proxy.hello("world", function(result) {
    console.log(result);
}, function(name, err) {
    console.error(err);
});

Tcp Server & Client

The Tcp Server & Client are used as same as the Http Server & Client.

To create a Tcp Server:

var server = hprose.Server.create("tcp://0.0.0.0:4321");

To create a Tcp Client:

var client = hprose.Client.create('tcp://127.0.0.1:4321');

Unix Socket Server & Client

The Unix Socket Server & Client are used as same as the Http Server & Client.

To create a Unix Socket Server:

var server = hprose.Server.create("unix:/tmp/my.sock");

To create a Unix Socket Client:

var client = hprose.Client.create('unix:/tmp/my.sock');

WebSocket Server & Client

The WebSocket Server & Client are used as same as the Http Server & Client.

To create a WebSocket Server:

var server = hprose.Server.create("ws://0.0.0.0:8080/");

To create a WebSocket Client:

var client = hprose.Client.create('ws://0.0.0.0:8080/');