package plugin import ( "context" "agent/cmd/agent/global" "linkfog.com/pluginx/pluginrpc" "linkfog.com/public/lib/l" ) func chatWithPlugin(client *pluginrpc.PluginGrpcClient, pluginName string, topicName string) { req := pluginrpc.NewReq(AgentSelfPlugin, pluginName, "", []byte{}) chatClient, err := client.Chat(context.Background(), req) if err != nil { l.Error("ChatClient err:", err) return } for { res, err := chatClient.Recv() if err != nil { l.Error("ChatClient receive err:", err) return } l.Infof("receive message: %v", res) global.HostInfoTail.MQTTInfo.PublishChan <- &global.Message{ Key: topicName, Payload: string(res.Data), } } }