import { TCompactProtocol , TBufferedTransport } from 'thrift' ; export default abstract class Payload { /**
     * Write this payload into the specified stream
     */ encode ( proto ) { return null ; } /**
     * Decodes thrift buffer into this payload
     */ decode ( data ) { return null ; } /**
     * Get topic this payload should published to
     * Only single-level topics have been observed,
     * but mqtt works with multiple, possibly dynamically
     * generated topics.
     */ getTopic ( ) { return null ; } /**
     * Static convenience method for writing a payload to a
     * buffered transport and returning it as a buffer
     */ static encodePayload ( payload ) { return new Promise < Buffer > ( ( resolve , reject ) => { const trans = new TBufferedTransport ( null , ( msg , seqid ) => { resolve ( msg ) ; } ) ; const proto = new TCompactProtocol ( trans ) ; payload . encode ( proto ) ; proto . flush ( ) ; } ) ; } }