adding a register method to rpc.
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/tutorialedge/go-grpc-tutorial/chat"
|
||||
"google.golang.org/grpc"
|
||||
"os"
|
||||
)
|
||||
|
||||
@@ -88,12 +89,12 @@ var seedCmd = &cobra.Command{
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// We need to enable specific gRPC services here
|
||||
//srv := rpc.Server()
|
||||
//helloworld.RegisterGreeterServer(srv, helloworld)
|
||||
s := chat.Server{}
|
||||
rpc.Register(func(srv *grpc.Server) {
|
||||
|
||||
chat.RegisterChatServiceServer(rpc.Server(), &s)
|
||||
s := chat.Server{}
|
||||
|
||||
chat.RegisterChatServiceServer(srv, &s)
|
||||
})
|
||||
|
||||
log.I.Ln("starting rpc server")
|
||||
|
||||
|
||||
@@ -64,8 +64,8 @@ func init() {
|
||||
server = grpc.NewServer()
|
||||
}
|
||||
|
||||
func Server() *grpc.Server {
|
||||
return server
|
||||
func Register(r func(srv *grpc.Server)) {
|
||||
r(server)
|
||||
}
|
||||
|
||||
func Start(ctx context.Context) {
|
||||
@@ -115,8 +115,6 @@ func Start(ctx context.Context) {
|
||||
|
||||
go server.Serve(tcpSock)
|
||||
|
||||
//network.ListenPing(netstack.PingAddrFromAddr(deviceIP))
|
||||
|
||||
isReady <- true
|
||||
|
||||
select {
|
||||
|
||||
Reference in New Issue
Block a user