代码拉取完成,页面将自动刷新
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()
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。