hprose / hprose-typescript Goto Github PK
View Code? Open in Web Editor NEWHprose 3.0 for TypeScript
License: MIT License
Hprose 3.0 for TypeScript
License: MIT License
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;
~~~~
调用方式:
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);
}
后正常
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();
为什么会这样呢
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.
我参照hprose-typescript中的用例,向本地客户端推送消息,报找不到方法:
UnhandledPromiseRejectionWarning: Error: Can't find this method >().
请问是不是少引了什么包?
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.
I use yarn add @types/phrose
But I can't find declare files of hprose.
Any solutions?
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
.
比如创建一个RPC Client:
let client = new Client('tcp4://127.0.0.1:41622/');
我如何判断这个client是否正确连接上了服务器?
有什么回调方法,或是错误捕获?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.