Coder Social home page Coder Social logo

hprose / hprose-typescript Goto Github PK

View Code? Open in Web Editor NEW
59.0 9.0 9.0 883 KB

Hprose 3.0 for TypeScript

License: MIT License

TypeScript 99.73% JavaScript 0.27%
hprose typescript rpc rpc-framework serialize serialization serializer cross-platform cross-language

hprose-typescript's Introduction

Hprose

Hprose 3.0 for TypeScript

Join the chat Build Status lerna

package name lastest version download
@hprose/io npm version npm download
@hprose/rpc-core npm version npm download
@hprose/rpc-plugin-circuitbreaker npm version npm download
@hprose/rpc-plugin-cluster npm version npm download
@hprose/rpc-plugin-limiter npm version npm download
@hprose/rpc-plugin-loadbalancer npm version npm download
@hprose/rpc-plugin-log npm version npm download
@hprose/rpc-plugin-oneway npm version npm download
@hprose/rpc-plugin-push npm version npm download
@hprose/rpc-plugin-reverse npm version npm download
@hprose/rpc-plugin-forward npm version npm download
@hprose/rpc-plugin-timeout npm version npm download
@hprose/rpc-codec-jsonrpc npm version npm download
@hprose/rpc-html5 npm version npm download
@hprose/rpc-node npm version npm download
@hprose/rpc-wx npm version npm download

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 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
  • TypeScript
  • ...

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

This project is the implementation of Hprose for TypeScript.

hprose-typescript's People

Contributors

andot avatar dependabot[bot] avatar yss1993 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hprose-typescript's Issues

Use hprose in React issue.

  1. npm i --S @hprose/html5
import * as hprose from '@hprose/html5';
const client = new hprose.Client('http://127.0.0.1:8255');

then:
TypeError: _hprose_rpc_html5__WEBPACK_IMPORTED_MODULE_4__.Client is not a constructor.

minify with uglifyjs-webpack-plugin and webpack4 failed

There is a react project implemented with typescript, and use hprose-ts to communicate with back-server.
To minify that project with uglifyjs-webpack-plugin and webpack 4, always get some errors like: 'ERROR in app.js from UglifyJs Unexpected token: keyword (const) [app.js:22505,0]'.
After many attempts, resolved this error with follow config of webpack:
'...
{
test: /.jsx?$/,
//exclude: /node_modules/,
include: /src|hprose-ts/,
use: {
loader: 'babel-loader',
options: {
...
}
}
}
...'
This is because hprose-ts has provide an es6 libs, but not be accepted by the uglifyjs.

使用hprose3.0报不支持tcp协议

import { Client } from '@hprose/rpc-core';
async function test() {
    const client = new Client('tcp://127.0.0.1:3000/');
    const proxy = await client.useServiceAsync(); 
}

执行useServiceAsync方法报并不支持tcp协议,是哪里用错了么?

Uncaught (in promise) Error: The protocol "tcp:" is not supported.

Error: This type server is not supported

import { Context, NextInvokeHandler, Service, Client, ClientContext, ServiceContext } from '@hprose/rpc-core';

    const service = new Service();
    service.addFunction(hello);
    const server = net.createServer();
    service.bind(server);
    server.listen(8412);
    const client = new Client('tcp://127.0.0.1:8412');
    const proxy = await client.useServiceAsync();
    const result = await proxy.hello('world');
    server.close();

为什么会这样呢

unix domain socket失败

调用方式:

const client = new Client('unix:///tmp/test.sock');

rpc-node里的SocketTransport.ts

case 'unix': {
                const options: net.IpcNetConnectOpts = Object.create(null);
                if (parser.path) {
                    options.path = parser.path;
                } else {
                    throw new Error('invalid unix path');
                }
                return net.connect(options);
            }

修改为

case 'unix:': {
                const options: net.IpcNetConnectOpts = Object.create(null);
                if (parser.path) {
                    options.path = parser.path;
                } else {
                    throw new Error('invalid unix path');
                }
                return net.connect(options);
            }

后正常

TS2717: Subsequent property declarations must have the same type.

   TypeScript diagnostics (customize using `[jest-config].globals.ts-jest.diagnostics` option):
    packages/@hprose/rpc-node/src/HttpHandler.ts:243:9 - error TS2717: Subsequent property declarations must have the same type.  Property 'http' must be of type 'HttpHandler', but here has type 'HttpHandler'.

    243         http: HttpHandler;
                ~~~~

 FAIL  packages/@hprose/rpc-node/test/Http.test.ts
  ● Test suite failed to run

    TypeScript diagnostics (customize using `[jest-config].globals.ts-jest.diagnostics` option):
    packages/@hprose/rpc-node/src/HttpHandler.ts:243:9 - error TS2717: Subsequent property declarations must have the same type.  Property 'http' must be of type 'HttpHandler', but here has type 'HttpHandler'.

    243         http: HttpHandler;
                ~~~~

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.