diff --git a/client/client.go b/client/client.go index a75c445..a1c7b2f 100644 --- a/client/client.go +++ b/client/client.go @@ -3,10 +3,13 @@ package client import ( crc "git.loafle.net/commons_go/rpc/client" crcrs "git.loafle.net/commons_go/rpc/client/rwc/socket" - csc "git.loafle.net/commons_go/server/client" + crr "git.loafle.net/commons_go/rpc/registry" ) -func New(addr string, clientHandler ClientHandler, socketHandler csc.SocketHandler) crc.Client { +func New(addr string, rpcInvoker crr.RPCInvoker) crc.Client { + clientHandler := newClientHandler(rpcInvoker) + socketHandler := newSocketHandler() + socketBuilder := NewSocketBuilder(addr, socketHandler) cRWCHandler := crcrs.New(socketBuilder) diff --git a/client/client_handlers.go b/client/client_handlers.go index 769379d..0b93873 100644 --- a/client/client_handlers.go +++ b/client/client_handlers.go @@ -6,7 +6,7 @@ import ( crr "git.loafle.net/commons_go/rpc/registry" ) -func NewClientHandler(rpcInvoker crr.RPCInvoker) ClientHandler { +func newClientHandler(rpcInvoker crr.RPCInvoker) ClientHandler { ch := &ClientHandlers{} ch.RPCInvoker = rpcInvoker ch.Codec = json.NewClientCodec() diff --git a/client/socket_handlers.go b/client/socket_handlers.go new file mode 100644 index 0000000..f02b4b4 --- /dev/null +++ b/client/socket_handlers.go @@ -0,0 +1,28 @@ +package client + +import ( + "net" + + csc "git.loafle.net/commons_go/server/client" +) + +type SocketHandlers struct { + csc.SocketHandlers +} + +func (sh *SocketHandlers) OnConnect(socketContext csc.SocketContext, conn net.Conn) { + sh.SocketHandlers.OnConnect(socketContext, conn) +} + +func (sh *SocketHandlers) OnDisconnect(soc csc.Socket) { + + sh.SocketHandlers.OnDisconnect(soc) +} + +func (sh *SocketHandlers) Validate() { + sh.SocketHandlers.Validate() +} + +func newSocketHandler() csc.SocketHandler { + return &SocketHandlers{} +}