2024-10-12 11:34:47 +02:00
|
|
|
package tcpclient
|
|
|
|
|
2024-10-22 20:02:14 +02:00
|
|
|
import "net"
|
|
|
|
|
2024-10-12 11:34:47 +02:00
|
|
|
type ClientOption func(conf *ClientConfiguration)
|
|
|
|
|
|
|
|
const (
|
|
|
|
statusBitNothing = 0
|
|
|
|
statusBitCustomErrorHandling = 1 << iota
|
|
|
|
)
|
|
|
|
|
|
|
|
func WithCustomErrorHandling(fun ErrorResolverFunc) ClientOption {
|
|
|
|
return func(conf *ClientConfiguration) {
|
|
|
|
conf.Status |= statusBitCustomErrorHandling
|
|
|
|
conf.ErrorResolver = fun
|
|
|
|
}
|
|
|
|
}
|
2024-10-22 20:02:14 +02:00
|
|
|
|
|
|
|
func WithServerHandler(fun func(server net.Conn)) ClientOption {
|
|
|
|
return func(conf *ClientConfiguration) {
|
|
|
|
conf.ServerHandlerFunc = fun
|
|
|
|
}
|
|
|
|
}
|