示例#1
0
// Connect
func (system *_System) Connect(name string, raddr string) (gorpc.Client, error) {
	builder := gorpc.NewClientBuilder(
		name,
		gorpc.BuildPipeline(time.Millisecond*10).Handler(
			"profile",
			gorpc.ProfileHandler,
		).Handler(
			"tunnel-client",
			func() gorpc.Handler {
				return system.newTunnelClient(raddr)
			},
		).Timeout(system.timeout),
	)

	builder.Reconnect(system.timeout)

	return gorpc.TCPConnect(builder, name, raddr)
}
示例#2
0
文件: rpc_test.go 项目: gsrpc/gorpc
		func() gorpc.Handler {
			return stateHandler
		},
	),
)

var clientBuilder = gorpc.NewClientBuilder(
	"test-client",
	gorpc.BuildPipeline(time.Millisecond*10).Handler(

		"dh-client",
		func() gorpc.Handler {
			return handler.NewCryptoClient(gorpc.NewDevice(), handler.NewDHKey(G, P))

		},
	).Handler(

		"heatbeat-client",

		func() gorpc.Handler {

			return handler.NewHeartbeatHandler(5 * time.Second)
		},
	),
)

var upgrader = websocket.Upgrader{} // use default options

func api(w http.ResponseWriter, r *http.Request) {
	c, err := upgrader.Upgrade(w, r, nil)
	if err != nil {