NatsWx.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package NatsServer
  2. import (
  3. "Cold_Api/controllers/lib"
  4. "Cold_Api/logs"
  5. "fmt"
  6. "time"
  7. )
  8. func Wx_GenerateQRCode(DeviceClass_id string) (string, bool) {
  9. logs.Println(" => Nats", lib.FuncName(), DeviceClass_id)
  10. // 请求-响应, 向 test3 发布一个 `help me` 请求数据,设置超时间3秒,如果有多个响应,只接收第一个收到的消息
  11. msg, err := lib.Nats.Request("Wx_GenerateQR", []byte(DeviceClass_id), 3*time.Second)
  12. if err != nil {
  13. fmt.Println(err)
  14. } else {
  15. fmt.Printf("Wx_GenerateQR : %s\n", string(msg.Data))
  16. return string(msg.Data), true
  17. }
  18. return string(msg.Data), false
  19. }
  20. func Wx_GenerateQRCode2(DeviceClass_id string) (string, bool) {
  21. logs.Println(" => Nats", lib.FuncName(), DeviceClass_id)
  22. // 请求-响应, 向 test3 发布一个 `help me` 请求数据,设置超时间3秒,如果有多个响应,只接收第一个收到的消息
  23. msg, err := lib.Nats.Request("Wx2_GenerateQR", []byte(DeviceClass_id), 3*time.Second)
  24. if err != nil {
  25. fmt.Println(err)
  26. } else {
  27. fmt.Printf("Wx2_GenerateQR : %s\n", string(msg.Data))
  28. return string(msg.Data), true
  29. }
  30. return string(msg.Data), false
  31. }