Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to make encoderStream protected? #86

Open
ac-allio opened this issue Apr 30, 2024 · 0 comments
Open

Is it possible to make encoderStream protected? #86

ac-allio opened this issue Apr 30, 2024 · 0 comments

Comments

@ac-allio
Copy link

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)
        }
      }
    })
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant