How do you send a message on reconnect?
pacedavis opened this issue · comments
I need to send a login message when the connection is reestablished. How do I do this?
You can just use the subscribeHandler
Thank you Lucas for the very quick reply! Can you give me a quick example of how I do that? I see hasSubscribeHandler, not sure where I capture events for subscribeHandler. Please excuse my ignorance.
You can just set the SubscribeHandler as field: https://github.com/recws-org/recws/blob/master/recws.go#L43
Let me know if this does not help - then i will create a quick example for you tomorrow
Should look like this:
var ws = &recws.RecConn{
RecIntvlMax: 10 * time.Minute,
SubscribeHandler: func() error {
// send your login message here
},
KeepAliveTimeout: 10 * time.Second,
}
Awesome. Thank you so much!