import Payload from './Payload' ; import { Thrift , TCompactProtocol , Int64 } from 'thrift' ; import Long from 'long' ; export default class PresenceStatePayload extends Payload { recipient : string ; sender : number ; state : boolean ; constructor ( recipientId , state ) { super ( ) ; this . recipient = recipientId . toString ( ) ; this . sender = 0 ; this . state = state ; } encode ( proto ) { proto . writeFieldBegin ( 'traceInfo' , Thrift . Type . STRING , 1 ) ; proto . writeString ( '' ) ; proto . writeFieldBegin ( 'recipient' , Thrift . Type . I64 , 1 ) ; proto . writeI64 ( new Int64 ( Buffer . from ( Long . fromString ( this . recipient ) . toBytes ( ) ) ) ) ; proto . writeFieldBegin ( 'sender' , Thrift . Type . I64 , 2 ) ; proto . writeI64 ( this . sender ) ; proto . writeFieldBegin ( 'state' , Thrift . Type . I32 , 3 ) ; proto . writeI32 ( this . state ? 1 : 0 ) ; proto . writeByte ( 0 ) ; return null ; } getTopic ( ) { return '/t_stp' ; } }