ing
This commit is contained in:
parent
24532a16bb
commit
7a72c4a5f6
|
@ -1,16 +1,15 @@
|
|||
package client
|
||||
|
||||
import (
|
||||
"git.loafle.net/commons_go/rpc"
|
||||
"git.loafle.net/commons_go/rpc/client"
|
||||
crcrwf "git.loafle.net/commons_go/rpc/client/rwc/websocket/fasthttp"
|
||||
cwfc "git.loafle.net/commons_go/websocket_fasthttp/client"
|
||||
)
|
||||
|
||||
func New(addr string, registry rpc.Registry) client.Client {
|
||||
func New(clientHandler ClientHandler, socketBuilder cwfc.SocketBuilder) client.Client {
|
||||
cRWCHandler := crcrwf.New(socketBuilder)
|
||||
|
||||
ch := NewClientHandler(addr, registry)
|
||||
cRWCHandler := crcrwf.New()
|
||||
c := client.New(ch, cRWCHandler)
|
||||
c := client.New(clientHandler, cRWCHandler)
|
||||
|
||||
return c
|
||||
}
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
package client
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
||||
"git.loafle.net/commons_go/rpc"
|
||||
"git.loafle.net/commons_go/rpc/client"
|
||||
"git.loafle.net/commons_go/rpc/protocol/json"
|
||||
)
|
||||
|
||||
func NewClientHandler(addr string, registry rpc.Registry) ClientHandler {
|
||||
func NewClientHandler(registry rpc.Registry) ClientHandler {
|
||||
ch := &ClientHandlers{}
|
||||
ch.addr = addr
|
||||
ch.RPCRegistry = registry
|
||||
ch.Codec = json.NewClientCodec()
|
||||
|
||||
|
@ -19,10 +16,4 @@ func NewClientHandler(addr string, registry rpc.Registry) ClientHandler {
|
|||
|
||||
type ClientHandlers struct {
|
||||
client.ClientHandlers
|
||||
|
||||
addr string
|
||||
}
|
||||
|
||||
func (ch *ClientHandlers) Connect() (net.Conn, error) {
|
||||
return net.Dial("unix", ch.addr)
|
||||
}
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
package client
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
crcrwf "git.loafle.net/commons_go/rpc/client/rwc/websocket/fasthttp"
|
||||
"git.loafle.net/commons_go/websocket_fasthttp/websocket"
|
||||
)
|
||||
|
||||
type ClientReadWriteCloseHandlers struct {
|
||||
crcrwf.ClientReadWriteCloseHandlers
|
||||
|
||||
Scheme string
|
||||
Host string
|
||||
Path string
|
||||
}
|
||||
|
||||
func (crwch *ClientReadWriteCloseHandlers) Connect() (interface{}, error) {
|
||||
u := url.URL{
|
||||
Scheme: crwch.Scheme,
|
||||
Host: crwch.Host,
|
||||
Path: crwch.Path,
|
||||
}
|
||||
var reqHeader http.Header
|
||||
reqHeader.Add("", "")
|
||||
|
||||
conn, res, err := websocket.DefaultDialer.Dial(u.String(), reqHeader)
|
||||
|
||||
return nil, fmt.Errorf("RPC Client RWC Handler: ClientHandlers method[Connect] is not implement")
|
||||
}
|
||||
|
||||
func (crwch *ClientReadWriteCloseHandlers) Validate() {
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user