Closed egorsmkv closed 3 years ago
Hi @egorsmkv!
I originally thought of this as out of scope for this library since you can implement it on the user side with the OnDisconnect callback. What would your use case of this feature be? I tend to prefer to leave things to the user to implement since it gives them more power to make the library do what they want.
Example on how to do it today:
var conn *eslgo.Conn // Global instance, could be part of a struct and then startConnection is a method on that struct.
// You will need to protect access to conn behind a mutex or another synchronization method, left out of this example for brevity
func startConnection() {
var err error
for { // Add a max retry counter here if desired
conn, err = eslgo.Dial("127.0.0.1:8021", "ClueCon", func() {
// We disconnected, start it again
go startConnection()
})
if err == nil {
break
}
time.Sleep(time.Minute)
}
}
Thanks, @winsock !
Hello!
I would like to see this feature in the library :)
I think, it is possible to implement with the
OnDisconnect
callback and global variables. Am I right?