This commit is contained in:
crusader 2017-12-05 16:21:32 +09:00
parent c55c459f39
commit 41382db599
3 changed files with 12 additions and 7 deletions

View File

@ -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")
}

View File

@ -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

View File

@ -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")
}