func newRouter() *router {
	router := &router{routes: list.New(), messages: make(chan *packets.PublishPacket)}
	return router
}
newRouter returns a new instance of a Router and channel which can be used to tell the Router
to stop
package mqtt
import (
	"container/list"
	"strings"
	"sync"
	"github.com/eclipse/paho.mqtt.golang/packets"
)
type route struct {
	topic    string
	callback MessageHandler
}
func match(route []string, topic []string) bool {
	if len(route) == 0 {
		return len(topic) == 0
	}
	if len(topic) == 0 {
		return route[0] == "#"
	}
	if route[0] == "#" {
		return true
	}
	if (route[0] == "+") || (route[0] == topic[0]) {
		return match(route[1:], topic[1:])
	}
	return false
}
func routeIncludesTopic(route, topic string) bool {
	return match(routeSplit(route), strings.Split(topic, "/"))
}
func routeSplit(route string) []string {
	var result []string
	if strings.HasPrefix(route, "$share") {
		result = strings.Split(route, "/")[2:]
	} else {
		result = strings.Split(route, "/")
	}
	return result
}
func (r *route) match(topic string) bool {
	return r.topic == topic || routeIncludesTopic(r.topic, topic)
}
type router struct {
	sync.RWMutex
	routes         *list.List
	defaultHandler MessageHandler
	messages       chan *packets.PublishPacket
}