use existing func to parse host id from topic

This commit is contained in:
Abhishek Kondur 2023-01-18 22:18:55 +05:30
parent 9a9eaec3d4
commit be2a730a24
2 changed files with 1 additions and 11 deletions

View file

@ -121,7 +121,7 @@ func UpdateNode(client mqtt.Client, msg mqtt.Message) {
// UpdateHost message Handler -- handles host updates from clients
func UpdateHost(client mqtt.Client, msg mqtt.Message) {
go func(msg mqtt.Message) {
id, err := getHostID(msg.Topic())
id, err := getID(msg.Topic())
if err != nil {
logger.Log(1, "error getting host.ID sent on ", msg.Topic(), err.Error())
return

View file

@ -94,13 +94,3 @@ func getID(topic string) (string, error) {
//the last part of the topic will be the node.ID
return parts[count-1], nil
}
// decodes a message queue topic and returns the embedded host.ID
func getHostID(topic string) (string, error) {
parts := strings.Split(topic, "/")
count := len(parts)
if count < 3 {
return "", fmt.Errorf("invalid topic")
}
return parts[2], nil
}