Exemple #1
0
func main() {
	// Create Babel service objects
	svc := new(gen.UserService)
	svc.SvcObj = NewUserServiceImpl()

	// Register the service with RPC
	rpc.Register(svc)

	// Register the service with Babel
	babel.Register(svc)

	// Set up Babel HTTP handlers and serve HTTP
	babel.HandleHTTP()
	http.Handle("/test/", http.StripPrefix("/test/", http.FileServer(http.Dir("../test"))))
	go func() { log.Fatal(http.ListenAndServe(":8333", nil)) }()

	//rpc.HandleHTTP(rpc.DefaultRPCPath, rpc.DefaultDebugPath)

	// set up network listener for json rpc
	l, e := net.Listen("tcp", ":8222")
	if e != nil {
		log.Fatal("listen error:", e)
	}

	for {
		conn, err := l.Accept()
		if err != nil {
			log.Fatal(err)
		}

		go jsonrpc.ServeConn(conn)
	}
}
Exemple #2
0
func main() {
	// Register the first service
	floatSvc := new(math.FloatService)
	floatSvc.SvcObj = new(impl.FloatServiceImpl)
	babel.Register(floatSvc)

	// Register the second service
	fractSvc := new(math.FractionService)
	fractSvc.SvcObj = new(impl.FractionServiceImpl)
	babel.Register(fractSvc)

	// Set up Babel HTTP handlers and serve HTTP
	babel.HandleHTTP()
	log.Fatal(http.ListenAndServe(":9999", nil))
}