func ClearRetainedMessage(config *Config, topic string, timeout time.Duration) error {
	return PublishMessage(config, &packet.Message{
		Topic:   topic,
		Payload: nil,
		QOS:     0,
		Retain:  true,
	}, timeout)
}
ClearRetainedMessage will connect to the specified broker and send an empty
retained message to force any already retained message to be cleared.
package client
import (
	"time"
	"github.com/256dpi/gomqtt/packet"
)
func ClearSession(config *Config, timeout time.Duration) error {
	newConfig := *config
	newConfig.CleanSession = true
	client := New()
	future, err := client.Connect(&newConfig)
	if err != nil {
		return err
	}
	err = future.Wait(timeout)
	if err != nil {
		return err
	}
	err = client.Disconnect()
	if err != nil {
		return err
	}
	return nil
}
func PublishMessage(config *Config, msg *packet.Message, timeout time.Duration) error {
	client := New()
	future, err := client.Connect(config)
	if err != nil {
		return err
	}
	err = future.Wait(timeout)
	if err != nil {
		return err
	}
	publishFuture, err := client.PublishMessage(msg)
	if err != nil {
		return err
	}
	err = publishFuture.Wait(timeout)
	if err != nil {
		return err
	}
	err = client.Disconnect()
	if err != nil {
		return err
	}
	return nil
}