func (router *Router) serve() {
	util.Log(router, "Started worker")
	defer util.Log(router, "Worker exited")
	defer close(router.inbound)
	for msg := range router.sock.Inbound() {
		switch msg := msg.(type) {
		case *knxnet.RoutingInd:
			router.pushInbound(msg.Payload)
		case *knxnet.RoutingBusy:
			router.sendMu.Lock()
			time.AfterFunc(msg.WaitTime, router.sendMu.Unlock)
		case *knxnet.RoutingLost:
			router.resendLost(msg.Count)
		}
	}
}
serve listens for incoming routing-related packets.
package knx
import (
	"container/list"
	"errors"
	"net"
	"sync"
	"time"
	"github.com/vapourismo/knx-go/knx/cemi"
	"github.com/vapourismo/knx-go/knx/knxnet"
	"github.com/vapourismo/knx-go/knx/util"
)
type RouterConfig struct {
	RetainCount uint
	Interface *net.Interface
}
var DefaultRouterConfig = RouterConfig{
	RetainCount: 32,
}
func checkRouterConfig(config RouterConfig) RouterConfig {
	if config.RetainCount == 0 {
		config.RetainCount = DefaultRouterConfig.RetainCount
	}
	return config
}
type Router struct {
	sock     knxnet.Socket
	config   RouterConfig
	inbound  chan cemi.Message
	sendMu   sync.Mutex
	retainer *list.List
}
func (router *Router) sendMultiple(messages []cemi.Message) {
	for _, message := range messages {
		router.Send(message)
	}
}
func (router *Router) resendLost(count uint16) {
	router.sendMu.Lock()
	defer router.sendMu.Unlock()
	if int(count) > router.retainer.Len() {
		count = uint16(router.retainer.Len())
	}
	messages := make([]cemi.Message, count)
	for i := len(messages) - 1; i >= 0; i-- {
		messages[i] = router.retainer.Remove(router.retainer.Back()).(cemi.Message)
	}
	go router.sendMultiple(messages)
}
func (router *Router) pushInbound(msg cemi.Message) {
	select {
	case router.inbound <- msg:
	default:
		go func() {
			defer func() { recover() }()
			router.inbound <- msg
		}()
	}
}