14 Star 51 Fork 12

Hprose / hprose-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.go 880 Bytes
一键复制 编辑 原始数据 按行查看 历史
Hprose 提交于 2016-10-31 21:45 . Update to hprose 2.0
package main
import (
"fmt"
"reflect"
"github.com/hprose/hprose-golang/rpc"
)
func logInvokeHandler(
name string,
args []reflect.Value,
context rpc.Context,
next rpc.NextInvokeHandler) (results []reflect.Value, err error) {
fmt.Printf("%s(%v) = ", name, args)
results, err = next(name, args, context)
fmt.Printf("%v %v\r\n", results, err)
return
}
func hello(name string) string {
return "Hello " + name + "!"
}
// HelloService is ...
type HelloService struct {
Hello func(string) (string, error)
Hi func(string) error
}
func main() {
server := rpc.NewTCPServer("")
server.AddFunction("hello", hello)
server.Handle()
client := rpc.NewClient(server.URI())
client.AddInvokeHandler(logInvokeHandler)
var helloService *HelloService
client.UseService(&helloService)
helloService.Hello("World")
helloService.Hi("World")
client.Close()
server.Close()
}
Go
1
https://gitee.com/andot/hprose-go.git
git@gitee.com:andot/hprose-go.git
andot
hprose-go
hprose-go
v2.0.4

搜索帮助