1234567891011121314151617181920 |
- package services
- import (
- "lzyd-message-api/common"
- "lzyd-message-api/wrapper"
- "strings"
- )
- func Publish(client *wrapper.Client, msg *wrapper.Message) error {
- // Topic规则: root/topic/liveroom/roomId`
- //name := "/typd" + strings.ToLower(msg.TargetType) + "/" + msg.Target
- name := strings.ToLower(msg.TargetType) + "/" + msg.Target
- topic := common.MqttClientPrefix + name
- err := client.Publish(topic, msg)
- if err != nil {
- return err
- }
- return nil
- }
|