func (d *DummyToken) Wait() bool {
	return true
}
Wait implements the Token Wait method.
package mqtt
import (
	"fmt"
	"sync"
	"time"
)
type MId uint16
type messageIds struct {
	sync.RWMutex
	index map[uint16]tokenCompletor
	lastIssuedID uint16  
}
const (
	midMin uint16 = 1
	midMax uint16 = 65535
)
func (mids *messageIds) cleanUp() {
	mids.Lock()
	for _, token := range mids.index {
		switch token.(type) {
		case *PublishToken:
			token.setError(fmt.Errorf("connection lost before Publish completed"))
		case *SubscribeToken:
			token.setError(fmt.Errorf("connection lost before Subscribe completed"))
		case *UnsubscribeToken:
			token.setError(fmt.Errorf("connection lost before Unsubscribe completed"))
		case nil:
			continue
		}
		token.flowComplete()
	}
	mids.index = make(map[uint16]tokenCompletor)
	mids.Unlock()
	DEBUG.Println(MID, "cleaned up")
}
func (mids *messageIds) freeID(id uint16) {
	mids.Lock()
	delete(mids.index, id)
	mids.Unlock()
}
func (mids *messageIds) claimID(token tokenCompletor, id uint16) {
	mids.Lock()
	defer mids.Unlock()
	if _, ok := mids.index[id]; !ok {
		mids.index[id] = token
	} else {
		old := mids.index[id]
		old.flowComplete()
		mids.index[id] = token
	}
	if id > mids.lastIssuedID {
		mids.lastIssuedID = id
	}
}
func (mids *messageIds) getID(t tokenCompletor) uint16 {
	mids.Lock()
	defer mids.Unlock()
	i := mids.lastIssuedID  
	looped := false         
	for {
		i++
		if i == 0 {  
			i++
			looped = true
		}
		if _, ok := mids.index[i]; !ok {
			mids.index[i] = t
			mids.lastIssuedID = i
			return i
		}
		if (looped && i == mids.lastIssuedID) || (mids.lastIssuedID == 0 && i == midMax) {  
			return 0  
		}
	}
}
func (mids *messageIds) getToken(id uint16) tokenCompletor {
	mids.RLock()
	defer mids.RUnlock()
	if token, ok := mids.index[id]; ok {
		return token
	}
	return &DummyToken{id: id}
}
type DummyToken struct {
	id uint16
}