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

Abstract nextPacket from Connection #52

Closed
invisal opened this issue Jun 6, 2020 · 2 comments
Closed

Abstract nextPacket from Connection #52

invisal opened this issue Jun 6, 2020 · 2 comments

Comments

@invisal
Copy link

invisal commented Jun 6, 2020

I was trying to implement cache_sha2_password. Since cache_sha2_password need several communication back and fore, it is not possible to do it with current buildAuth.

I think it is better for us to have ability to pass connection and use nextPacket. But since nextPacket is private, it is not possible to use it inside the handleHandshake.

export class Connection {
  //...
  private async _connect() {
      // ....
      await handleHandshake(this, this.client.config);
      // ....
  }
}

Another way we wrap the raw connection with another helper class. Then we just pass helper class to other function.

class ConnectionHelper {
   next(): Promise<RecievePacket>
   send(data, sequence?: number): Promise<void>
   startTls() // for future SSL support implementation
}

Then in the Connection class

class Connection {
    private raw: Deno.Conn;
    private conn: ConnectionHelper;

    private async _connect() {
       // ....
      this.conn = new ConnectionHelper(raw);
      await handleHandshake(this.conn, this.client.config);
      // ....
    }
}
@manyuanrong
Copy link
Member

I think it is ok

@wenjoy
Copy link
Collaborator

wenjoy commented Jun 16, 2020

@invisal What's the progress on it? Have u r alreday working on a branch? I also would like to give a hand.

@invisal invisal closed this as completed Dec 19, 2020
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

3 participants