func NewMsgServer(network Service, name string, requestLifetime time.Duration, c chan service.DirectMessage, logger log.Log) *MessageServer {
	p := &MessageServer{
		Log:                logger,
		name:               name,
		resHandlers:        make(map[uint64]func(msg []byte)),
		pendingQueue:       list.New(),
		network:            network,
		ingressChannel:     network.RegisterDirectProtocolWithChannel(name, c),
		msgRequestHandlers: make(map[MessageType]func(message Message) []byte),
		requestLifetime:    requestLifetime,
		exit:               make(chan struct{}),
		workerLimiter:      make(chan struct{}, runtime.NumCPU()),
	}
	go p.readLoop()
	return p
}
NewMsgServer registers a protocol and returns a new server to declare request and response handlers on.
package server
import (
	"container/list"
	"runtime"
	"sync"
	"sync/atomic"
	"time"
	"github.com/libonomy/libonomy-p2p/log"
	"github.com/libonomy/libonomy-p2p/p2p/p2pcrypto"
	"github.com/libonomy/libonomy-p2p/p2p/service"
)
type MessageType uint32
type Message interface {
	service.DirectMessage
	Data() service.Data
}
func extractPayload(m Message) []byte {
	data := m.Data().(*service.DataMsgWrapper)
	return data.Payload
}
type Item struct {
	id        uint64
	timestamp time.Time
}
type MessageServer struct {
	log.Log
	ReqID              uint64  
	name               string  
	network            Service
	pendMutex          sync.RWMutex
	pendingQueue       *list.List                                    
	resHandlers        map[uint64]func(msg []byte)                   
	msgRequestHandlers map[MessageType]func(message Message) []byte  
	ingressChannel     chan service.DirectMessage                    
	requestLifetime    time.Duration                                 
	workerCount        sync.WaitGroup
	workerLimiter      chan struct{}
	exit               chan struct{}
}
type Service interface {
	RegisterDirectProtocolWithChannel(protocol string, ingressChannel chan service.DirectMessage) chan service.DirectMessage
	SendWrappedMessage(nodeID p2pcrypto.PublicKey, protocol string, payload *service.DataMsgWrapper) error
}