// message fetcher func fetcher_task() { //connect to game service clients, err := services.GetAllService(services.SERVICE_GAME) if err != nil { log.Critical(err) os.Exit(-1) } for _, cli := range clients { service, _ := cli.(proto.GameServiceClient) stream, err := service.Notify(context.Background(), &proto.Game_Nil{}) if err != nil { log.Critical(err) os.Exit(-1) } go func() { for { p, err := stream.Recv() if err == io.EOF { log.Infof("stream recv EOF err :%v", err) return } if err != nil { log.Critical("stream recv gs err", err) continue } registry.Deliver(p.Uid, p.Content) } }() } }
func (f *forwarder) recv(key string, cli GameService_PacketClient) { for { in, err := cli.Recv() if err == io.EOF { log.Infof("stream recv EOF err : %v", err) return } if err != nil { log.Critical("Failed to receive a note : %v", err) continue } registry.Deliver(in.Uid, in.Content) } }