-
Notifications
You must be signed in to change notification settings - Fork 2
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
keep connected && transport error handler #2
base: master
Are you sure you want to change the base?
Conversation
cravler
commented
Sep 17, 2018
Thanks for your interest in this project. I'am Ok to extend the client interface with OnTransportError(this should be pretty useful in mobile devices). Also, be aware that i'm probably going to break some API like thank you! |
transport/websocket/websocket.go
Outdated
@@ -60,17 +62,17 @@ func (w *Websocket) Init(endpoint string, options *transport.Options) error { | |||
return nil | |||
} | |||
|
|||
func (w *Websocket) readWorker() 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.
keep the current function signature
transport/websocket/websocket.go
Outdated
for { | ||
select { | ||
case err := <-w.stopCh: | ||
return err | ||
panic(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.
please do not panic in user libraries, I'm sure you don't want to panic when you disconnect the client (see w.stopCh)
transport/websocket/websocket.go
Outdated
default: | ||
} | ||
var payload []message.Message | ||
err := w.conn.ReadJSON(&payload) | ||
if err != nil { | ||
return err | ||
panic(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.
do not panic if the read fail, FAYE protocol should handle auto-reconnect( this is going to be handled in the upcoming commits )
@@ -83,6 +85,16 @@ func (w *Websocket) readWorker() error { | |||
if transport.IsMetaMessage(msg) { | |||
//handle it | |||
switch msg.Channel { | |||
case transport.MetaConnect: |
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 is going to be handled in the upcoming commits as well, we shouldn't reconnect always.
If the server sends advise.reconnect==none we should stop
I understood that work in progress and there are might be breaking changes, but thanks for explanations. |