ing
This commit is contained in:
parent
d57710e28e
commit
11734b2eb5
|
@ -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)
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
28
client/socket_handlers.go
Normal file
28
client/socket_handlers.go
Normal file
|
@ -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{}
|
||||
}
|
Loading…
Reference in New Issue
Block a user