func NewMessage(b []byte) (Message, error) {
	if len(b) < MessageHeaderSize {
		return nil, errors.New("message length too small")
	}
	mh, err := NewMessageHeader(b[:MessageHeaderSize])
	if err != nil {
		return nil, err
	}
	if uint32(len(b)) != mh.Length {
		return nil, errors.New("message length invalid")
	}
	if mh.ControlType != 3 {
		return mh, nil
	}
	mp, ok := messageParsers[mh.Type]
	if !ok {
		return nil, errors.New("unrecognized message type")
	}
	return mp(b)
}
// NewMessage returns a new message from a given byte array based on its type
NewMessage returns a new message from a given byte array based on its type
// NewMessage returns a new message from a given byte array based on its type
func NewMessage(b []byte) (Message, error) {
	if len(b) < MessageHeaderSize {
		return nil, errors.New("message length too small")
	}
	mh, err := NewMessageHeader(b[:MessageHeaderSize])
	if err != nil {
		return nil, err
	}
	if uint32(len(b)) != mh.Length {
		return nil, errors.New("message length invalid")
	}
	if mh.ControlType != 3 {
		return mh, nil
	}
	mp, ok := messageParsers[mh.Type]
	if !ok {
		return nil, errors.New("unrecognized message type")
	}
	return mp(b)
}
func NewMessage ( b [ ] byte ) ( Message , error ) { if len ( b ) < MessageHeaderSize { return nil , errors . New ( " " ) } mh , err := NewMessageHeader ( b [ : MessageHeaderSize ] ) if err != nil { return nil , err } if uint32 ( len ( b ) ) != mh . Length { return nil , errors . New ( " " ) } if mh . ControlType != 3 { return mh , nil } mp , ok := messageParsers [ mh . Type ] if ! ok { return nil , errors . New ( " " ) } return mp ( b ) }
NewMessage returns a new message from a given byte array based on its type
NewMessage returns a new message from a given byte array based on its type