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") logging.Logger().Panic("Client Socket: SocketContext must be specified")
} }
sh := sb.SocketHandler() sh := sb.GetSocketHandler()
if nil == sh { if nil == sh {
logging.Logger().Panic("Client Socket: SocketHandler must be specified") logging.Logger().Panic("Client Socket: SocketHandler must be specified")
} }

View File

@ -10,10 +10,10 @@ import (
type SocketBuilder interface { type SocketBuilder interface {
SocketContext(parent cuc.Context) SocketContext SocketContext(parent cuc.Context) SocketContext
SocketHandler() SocketHandler
Dial(network, address string) (net.Conn, error) Dial(network, address string) (net.Conn, error)
GetSocketHandler() SocketHandler
GetNetwork() string GetNetwork() string
GetAddress() string GetAddress() string
GetTLSConfig() *tls.Config GetTLSConfig() *tls.Config

View File

@ -11,9 +11,10 @@ import (
) )
type SocketBuilders struct { type SocketBuilders struct {
Network string SocketHandler SocketHandler
Address string Network string
TLSConfig *tls.Config Address string
TLSConfig *tls.Config
HandshakeTimeout time.Duration HandshakeTimeout time.Duration
KeepAlive time.Duration KeepAlive time.Duration
@ -25,8 +26,8 @@ func (sb *SocketBuilders) SocketContext(parent cuc.Context) SocketContext {
return newSocketContext(parent) return newSocketContext(parent)
} }
func (sb *SocketBuilders) SocketHandler() SocketHandler { func (sb *SocketBuilders) GetSocketHandler() SocketHandler {
return NewSocketHandler() return sb.SocketHandler
} }
func (sb *SocketBuilders) GetNetwork() string { func (sb *SocketBuilders) GetNetwork() string {
@ -69,6 +70,10 @@ func (sb *SocketBuilders) GetLocalAddress() net.Addr {
} }
func (sb *SocketBuilders) Validate() { func (sb *SocketBuilders) Validate() {
if nil == sb.SocketHandler {
logging.Logger().Panic("Client Socket: SocketHandler must be specified")
}
if "" == sb.Network { if "" == sb.Network {
logging.Logger().Panic("Client Socket: Network must be specified") logging.Logger().Panic("Client Socket: Network must be specified")
} }