TimelordUK / jspurefix

native typescript FIX engine
MIT License
60 stars 28 forks source link

Is it possible to make encoderStream protected? #86

Open ac-allio opened 5 months ago

ac-allio commented 5 months ago

Hi,

I want to update the encoderStream method in MsgTransmitter to return some object in the callback. Is it possible to make it protected so that I can override it? Please check the pseudo code below:

export abstract class MsgTransmitter extends events.EventEmitter {
  public send (msgType: string, obj: ILooseObject, callback: (error: Error, data: any) => void): void {
    this.encodeStream.write(new MsgPayload(msgType, obj), callback);
  }

  ...
  private encoderStream (): Transform {
    const transmitter = this
    return new Transform({
      writableObjectMode: true,
      transform (payload: MsgPayload, encoding, done: Function) {
        try {
          ...
          const state = transmitter.encodeMessage(msgType, payload.obj)
          ...
          done(undefined, state) <--- This is what I want to update
        } catch (e) {
          done(e)
        }
      }
    })
  }
}