hprose 3.0.5

  • Readme
  • Changelog
  • Example
  • Installing
  • 73


Hprose 3.0 for Dart #

Join the chat Build Status Pub

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 Dart.

3.0.0-beta.1 #

  • Initial version, created by andot

3.0.0-beta.2 #

  • Fixed some hints.
  • Added CHANGELOG.md.

3.0.0-beta.3 #

  • Fixed some hints.

3.0.0-beta.4 #

  • Fixed some hints.
  • Added flutter, web and other platforms support.

3.0.0 #

  • Added Dart 2.0 support.
  • Added Flutter support.
  • Added Service implementation.
  • Added TCP, UDP, WebSocket support.
  • Added middleware support.
  • Added JSONRPC support.
  • Added Circuit Breaker plugin.
  • Added Cluster plugin.
  • Added Limiter plugin.
  • Added Load Balance plugin.
  • Added Log plugin.
  • Added Oneway call plugin.
  • Added Push plugin.
  • Added Reverse RPC plugin.

3.0.1 #

  • Added headers on JsonRpc.
  • Added exists & idlist for caller.
  • Added names property on Service.
  • Fixed ClientContext.
  • Fixed oneway plugin.
  • Fixed ConcurrentLimiter plugin.
  • Added remoteAddress & localAddress on ServiceContext.
  • Added request method on Client.
  • Improved Method.
  • Added httpStatusCode & httpStatusText on ClientContext.

3.0.2 #

  • Added google app engine support.

3.0.3 #

  • Improved google app engine support.

3.0.4 #

  • Added httpHeaders on HttpHandler.


library hprose_example;

import 'dart:async';
import 'dart:io';
import 'package:hprose/io.dart';
import 'package:hprose/rpc.dart';

String hello(String name) {
  return 'hello $name';

Future<int> sum(int a, int b, [int c = 0, int d = 10]) async {
  await Future.delayed(new Duration(milliseconds: 1));
  return a + b + c + d;

String getAddress(String name, ServiceContext context) {
  return '$name : ${context.host}';

class User {
  String name;
  int age;
  bool male;
  User([this.name, this.age, this.male]);
  factory User.fromJson(Map<String, dynamic> json) {
    return new User(json['name'], json['age'], json['male']);
  Map<String, dynamic> toJson() =>
      {'name': this.name, 'age': this.age, 'male': this.male};

User createUser(String name, {int age, bool male, Context context}) {
  final serviceContext = context as ServiceContext;
  return new User(name, age, male);

void main() async {
  TypeManager.register((data) => User.fromJson(data),
      {'name': String, 'age': int, 'male': bool});
  final service = new Service();
  final server = await HttpServer.bind('', 8000);
  final client = new Client(['']);
  final proxy = client.useService();
  print(await proxy.hello<String>('world'));
  final r1 = proxy.sum<int>(1, 2);
  final r2 = proxy.sum<int>(1, 2, 3);
  print(await proxy.sum<int>(r1, r2, 3, 4));
  print(await proxy.getAddress<String>('localhost'));
  User user = await proxy.createUser<User>('张三', age: 18, male: true);

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  hprose: ^3.0.5

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:hprose/hprose.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Nov 7, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.0
  • pana: 0.12.21


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:hprose/hprose.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
Dev dependencies
test any