import Dealer from './dealer' ; import { IEndpoint , Msg } from './types' ; import { Buffer } from "buffer" ; export default class Req extends Dealer { private static bottom = Buffer . alloc ( 0 ) ; receivingReply : boolean ; constructor ( ) { super ( ) ; this . receivingReply = false ; } protected xsend ( msg ) { if ( this . receivingReply ) throw new Error ( "cannot send another request" ) ; const withBottom = [ Req . bottom , ... msg ] ; super . xsend ( withBottom ) ; this . receivingReply = true ; } protected xrecv ( endpoint , bottom , ... frames ) { if ( ! this . receivingReply ) return ; if ( frames . length === 0 || bottom . length !== 0 ) return ; this . receivingReply = false ; super . xrecv ( endpoint , ... frames ) ; } }