import { Message , MessageHeader } from "./Message" ; description export class ProtoMessage < T > extends Message { description buffer : Uint8Array = null ; description private type : any = null ; description data : T = null ; constructor ( protoType ? ) { super ( ) ; if ( protoType ) { this . type = protoType ; this . data = new protoType ( ) ; } else { cc . error ( "没有指定proto数据类型" ) ; } } description encode ( ) { this . buffer = this . type . encode ( this . data ) . finish ( ) ; if ( this . buffer ) { return true ; } return false ; } description decode ( data ) { if ( data ) { this . buffer = data ; this . data = this . type . decode ( this . buffer ) ; return true ; } return false ; } } export class ProtoMessageHeader extends MessageHeader { }