This commit is contained in:
crusader 2017-12-05 16:29:42 +09:00
parent 6614bd5489
commit 0fc50612a4
5 changed files with 8 additions and 42 deletions

View File

@ -6,7 +6,8 @@ import (
csc "git.loafle.net/commons_go/server/client" csc "git.loafle.net/commons_go/server/client"
) )
func New(clientHandler ClientHandler, socketBuilder csc.SocketBuilder) crc.Client { func New(addr string, clientHandler ClientHandler, socketHandler csc.SocketHandler) crc.Client {
socketBuilder := NewSocketBuilder(addr, socketHandler)
cRWCHandler := crcrs.New(socketBuilder) cRWCHandler := crcrs.New(socketBuilder)
c := crc.New(clientHandler, cRWCHandler) c := crc.New(clientHandler, cRWCHandler)

View File

@ -4,14 +4,12 @@ import (
csc "git.loafle.net/commons_go/server/client" csc "git.loafle.net/commons_go/server/client"
) )
func NewSocketBuilder(address string) csc.SocketBuilder { func NewSocketBuilder(address string, socketHandler csc.SocketHandler) csc.SocketBuilder {
return newSocketBuilder(address) sb := newSocketBuilder(address)
sb.SocketHandler = socketHandler
return sb
} }
type SocketBuilders struct { type SocketBuilders struct {
csc.SocketBuilders csc.SocketBuilders
} }
func (sb *SocketBuilders) SocketHandler() csc.SocketHandler {
return NewSocketHandler()
}

View File

@ -1,10 +1,6 @@
package client package client
import ( func newSocketBuilder(address string) *SocketBuilders {
csc "git.loafle.net/commons_go/server/client"
)
func newSocketBuilder(address string) csc.SocketBuilder {
sb := &SocketBuilders{} sb := &SocketBuilders{}
sb.Network = "unix" sb.Network = "unix"
sb.Address = address sb.Address = address

View File

@ -3,11 +3,10 @@ package client
import ( import (
"net" "net"
csc "git.loafle.net/commons_go/server/client"
"gopkg.in/natefinch/npipe.v2" "gopkg.in/natefinch/npipe.v2"
) )
func newSocketBuilder(address string) csc.SocketBuilder { func newSocketBuilder(address string) *SocketBuilders {
sb := &SocketBuilders{} sb := &SocketBuilders{}
sb.Network = "pipe" sb.Network = "pipe"
sb.Address = address sb.Address = address

View File

@ -1,28 +0,0 @@
package client
import (
"log"
"net"
csc "git.loafle.net/commons_go/server/client"
)
type SocketHandlers struct {
csc.SocketHandlers
}
func (sh *SocketHandlers) OnConnect(socketContext csc.SocketContext, conn net.Conn) {
log.Printf("OnConnect res: %v \n", conn)
}
func (sh *SocketHandlers) OnDisconnect(soc csc.Socket) {
log.Printf("OnDisconnect \n")
}
func (sh *SocketHandlers) Validate() {
sh.SocketHandlers.Validate()
}
func NewSocketHandler() csc.SocketHandler {
return &SocketHandlers{}
}