Hprose使用说明 · Hexo

Hprose使用说明 · Hexo

简介Hprose(High Performance Remote Object Service Engine)是一款先进的轻量级、跨语言、跨平台、无侵入式、高性能动态远程对象调用引擎库。它不仅简单易用,而且功能强大。 你无需专门学习,只需看上几眼,就能用它轻松构建分布式应用系统。

使用手册案例(php)安装

使用composer require hprose/hprose如果你正在使用 composer 管理你的项目,那么你不需要做任何特别处理。只要在 composer.json 中的 require 段添加了对 hprose/hprose 的引用就可以了。如果你需要 swoole 支持,添加 hprose/hprose-swoole 就可以了。然后在代码中这样引用

服务端123456789101112131415addFunction('hello');$server->start();

客户端1234use Hprose\Client;$client=Client::create('http://localhost/',false);echo $client->hello("World");

案例(go)安装123go get github.com/gorilla/websocketgo get github.com/valyala/fasthttpgo get github.com/hprose/hprose-golang

使用服务端12345678910111213141516package mainimport( "net/http" "github.com/hprose/hprose-golang/rpc" )func hello(name string) string { return "Hello" + name + "!"}func main() { service := rpc.NewHTTPService() service.AddFunction("hello", hello, rpc.Options{}) http.ListenAndServer(":8080",service)}

客户端123456789101112131415161718192021package mainimport ( "fmt" "github.com/hprose/hprose-golang/rpc" )type Stub struct { Hello func(string) (string, error) AsyncHello func(func(string, error),string) `name:"hello"`}func main() { client := rpc.NewClient("http://127.0.0.1:8080/") var stub *Stub client.UseService(&stub) stub.AsyncHello(func(result string,err error) { fmt.Println(result, error) },"async world") fmt.Println(stub.Hello("world"))}

相关手记

365体育投注网站 qq保护模式多长时间自动解除
365体育投注网站 win10图标乱码怎么办_win10电脑桌面图标名称乱码恢复方法
365bet投注网 卫星发射直播频道(中国现在有多少颗电视直播卫星)
365bet投注网 如何在平板上安装下载快手:全面指南,快手下载ipad版
365bet线上网址 NVIDIA GeForce GTX 670 2gb 电脑显卡
365体育投注网站 三星9100二手什么价格

三星9100二手什么价格

07-14 👁️ 777