ing
This commit is contained in:
parent
6614bd5489
commit
0fc50612a4
|
@ -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)
|
||||||
|
|
|
@ -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()
|
|
||||||
}
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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{}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user