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

Make the close reason available to application code #29

Closed
wants to merge 5 commits into from

Conversation

dvdplm
Copy link
Contributor

@dvdplm dvdplm commented Mar 30, 2021

When a remote sends us a CLOSE message it may contain a reason code and "application data" with further details about why the connection was closed.

Before this PR there was no way for applications using soketto to know what the code/data was sent from the remote.

Further context here.

Copy link
Contributor

@tomaka tomaka left a comment

Choose a reason for hiding this comment

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

If I understand correctly the design of this crate, I think this PR has a fundamental problem: the Error::Closed enum as it currently is represents a way to signal to the user that a close frame has been sent/received in the past, and not as a way to signal instantaneously that a close frame has been received.

To me, there should instead of a new variant added to Incoming to contain the close reason. As mentioned, Error::Closed means "you can't do that because the connection is already closed".

src/connection.rs Outdated Show resolved Hide resolved
Comment on lines +599 to +600
code: u16,
descr: Option<String>,
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose you want to access these fields

Suggested change
code: u16,
descr: Option<String>,
pub code: u16,
pub descr: Option<String>,

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
@dvdplm
Copy link
Contributor Author

dvdplm commented Apr 14, 2021

Closing in favour of #31

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