func Encode(pack MessagePack) (bytes.Buffer, error) {
	switch pack.Type() {
	case utp.DISCONNECT:
		return pack.(*utp.Disconnect).ToBinary()
	case utp.PUBLISH:
		return pack.(*utp.Publish).ToBinary()
	case utp.FLOWCONTROL:
		return pack.(*utp.ControlMessage).ToBinary()
	default:
		return bytes.Buffer{}, fmt.Errorf("message::Encode: Invalid zero-length packet type %d", pack.Type())
	}
}
// Encode encodes the message into binary data
Encode encodes the message into binary data
// Encode encodes the message into binary data
func Encode(pack MessagePack) (bytes.Buffer, error) {
	switch pack.Type() {
	case utp.DISCONNECT:
		return pack.(*utp.Disconnect).ToBinary()
	case utp.PUBLISH:
		return pack.(*utp.Publish).ToBinary()
	case utp.FLOWCONTROL:
		return pack.(*utp.ControlMessage).ToBinary()
	default:
		return bytes.Buffer{}, fmt.Errorf("message::Encode: Invalid zero-length packet type %d", pack.Type())
	}
}
func Encode ( pack MessagePack ) ( bytes . Buffer , error ) { switch pack . Type ( ) { case utp . DISCONNECT : return pack . ( * utp . Disconnect ) . ToBinary ( ) case utp . PUBLISH : return pack . ( * utp . Publish ) . ToBinary ( ) case utp . FLOWCONTROL : return pack . ( * utp . ControlMessage ) . ToBinary ( ) default : return bytes . Buffer { } , fmt . Errorf ( " " , pack . Type ( ) ) } }
Encode encodes the message into binary data
Encode encodes the message into binary data