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
refactor: better client connection state management #364
Conversation
} | ||
|
||
c.state = ConnStateDisconnected | ||
c.errc <- err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the BASIC example, if an error is returned here, the client will exit. In previous versions, the server dropped without an error。
core/client.go
Outdated
|
||
stream.Close() | ||
if closeConn { | ||
c.conn.CloseWithError(yerr.ErrorCodeClientAbort.To(), err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should more error type checking be added so that the server knows exactly what the error code is and why? For example, something like this:
if e, ok := err.(*quic.ApplicationError); ok {
c.logger.Printf("%s[%s]connection closed by application error: %v", ClientLogPrefix, c.state, e)
c.conn.CloseWithError(e.ErrorCode, e.Error())
} else if e, ok := err.(*yerr.YomoError); ok {
c.logger.Printf("%s[%s]connection closed by yomo error: %v", ClientLogPrefix, c.state, e)
c.conn.CloseWithError(e.ErrorCode().To(), e.Error())
} else {
c.conn.CloseWithError(yerr.ErrorCodeClientAbort.To(), err.Error())
}
c.conn.CloseWithError(yerr.To(yerr.ErrorCodeRejected), v.Message()) | ||
c.errc <- errors.New(v.Message()) | ||
break | ||
return true, true, errors.New(v.Message()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it better to use YomoError? Like this:
return true, true, yerr.New(yerr.ErrorCodeRejected, errors.New(v.Message()))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏼
This change is