diff --git a/client/socket.go b/client/socket.go index d949ac9..f9e26e3 100644 --- a/client/socket.go +++ b/client/socket.go @@ -26,7 +26,7 @@ func NewSocket(sb SocketBuilder, parentContext cuc.Context) (Socket, error) { logging.Logger().Panic("Client Socket: SocketContext must be specified") } - sh := sb.SocketHandler() + sh := sb.GetSocketHandler() if nil == sh { logging.Logger().Panic("Client Socket: SocketHandler must be specified") } diff --git a/client/socket_builder.go b/client/socket_builder.go index 593b1c4..4bea4a0 100644 --- a/client/socket_builder.go +++ b/client/socket_builder.go @@ -10,10 +10,10 @@ import ( type SocketBuilder interface { SocketContext(parent cuc.Context) SocketContext - SocketHandler() SocketHandler Dial(network, address string) (net.Conn, error) + GetSocketHandler() SocketHandler GetNetwork() string GetAddress() string GetTLSConfig() *tls.Config diff --git a/client/socket_builders.go b/client/socket_builders.go index e497b33..d53cee6 100644 --- a/client/socket_builders.go +++ b/client/socket_builders.go @@ -11,9 +11,10 @@ import ( ) type SocketBuilders struct { - Network string - Address string - TLSConfig *tls.Config + SocketHandler SocketHandler + Network string + Address string + TLSConfig *tls.Config HandshakeTimeout time.Duration KeepAlive time.Duration @@ -25,8 +26,8 @@ func (sb *SocketBuilders) SocketContext(parent cuc.Context) SocketContext { return newSocketContext(parent) } -func (sb *SocketBuilders) SocketHandler() SocketHandler { - return NewSocketHandler() +func (sb *SocketBuilders) GetSocketHandler() SocketHandler { + return sb.SocketHandler } func (sb *SocketBuilders) GetNetwork() string { @@ -69,6 +70,10 @@ func (sb *SocketBuilders) GetLocalAddress() net.Addr { } func (sb *SocketBuilders) Validate() { + if nil == sb.SocketHandler { + logging.Logger().Panic("Client Socket: SocketHandler must be specified") + } + if "" == sb.Network { logging.Logger().Panic("Client Socket: Network must be specified") }