Skip to content

flow control handling#304

Merged
Tyriar merged 24 commits into
microsoft:masterfrom
jerch:flowcontrol
May 22, 2019
Merged

flow control handling#304
Tyriar merged 24 commits into
microsoft:masterfrom
jerch:flowcontrol

Conversation

@jerch

@jerch jerch commented May 22, 2019

Copy link
Copy Markdown
Collaborator

This PR introduces automatic flow control handling for node-pty.

Instead of relying on XON/OFF flow control is done by pause and resume of the underlying socket. This way we can ensure it to work even if XON/XOFF is not available.

The PAUSE/RESUME messages excepted default to XON/OFF control codes. Since some ppl customize these control codes the messages can be changed via ctor options or arguments for enableFlowControlHandling.

@Tyriar: Also wrote test cases, but those still need to be adopted for windows.

Comment thread src/interfaces.ts Outdated
gid?: number;
encoding?: string;
handleFlowControl?: boolean;
flowPause?: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably doesn't need to be configurable? If people want it we could always add it at a later point if there's the need.

@jerch jerch May 22, 2019

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well if we want this to work in xterm.js with zsh where ppl tend to rebind XON/XOFF (those are the defaults) we already have that use case?

Comment thread src/terminal.ts Outdated
return;
}
this._realWrite = this.write;
this.write = (data: string) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe write should be a (data: string) => void property on terminal.ts and it can be assigned by unix/windowsTerminal? Feels so dodgy monkey patching class methods.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

@jerch jerch May 22, 2019

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it this way: write is now provided as default impl flowcontrol aware, the derived classes instead set _writeMethod to their impl. _writeMethod gets called by Terminal.write later on.
Tests are still passing 😄

Comment thread src/terminal.ts Outdated
/**
* Disable automatic flow control handling.
*/
public disableFlowHandling(): void {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Toggling this after creation seems like something no one will need?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah this will be needed for binary transport (for things like zmodem protocol). Binary data tend to contain any sequence by accident, thus ppl need a possibility to disable (and later reenable) it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would it work at all with zmodem then?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zmodem would search for XON/XOFF and escape it with ZDLE char (xor'ed?). Not sure about the implications but I think the control codes are used for its message framing, too. Cannot make much sense from the lines here: https://stackoverflow.com/a/9710116

@Tyriar Tyriar added this to the 0.9.0 milestone May 22, 2019
@Tyriar Tyriar closed this May 22, 2019
@Tyriar Tyriar reopened this May 22, 2019
jerch added 2 commits May 22, 2019 21:07
- default write is provided by Terminal with flowcontrol
- derived classes attach their write implementation to _writeMethod
@jerch jerch closed this May 22, 2019
@jerch jerch reopened this May 22, 2019
Comment thread typings/node-pty.d.ts Outdated
Comment thread typings/node-pty.d.ts Outdated
Comment thread src/terminal.ts Outdated
Comment thread src/terminal.ts Outdated
Comment thread src/terminal.ts Outdated
Comment thread typings/node-pty.d.ts Outdated
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

Successfully merging this pull request may close these issues.

2 participants