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 Issues

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;
                ~~~~

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);
            }

后正常

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();

为什么会这样呢

使用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.

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.

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.

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.