diff --git a/client/client.go b/client/client.go index e793514..ad8cc50 100644 --- a/client/client.go +++ b/client/client.go @@ -2,8 +2,8 @@ package client import ( "fmt" - "io" "log" + "net" "runtime" "sync" "sync/atomic" @@ -31,7 +31,7 @@ type Client interface { type client struct { ch ClientHandler - rwc io.ReadWriteCloser + conn net.Conn pendingRequestsCount uint32 pendingRequests map[interface{}]*CallState @@ -51,7 +51,7 @@ func (c *client) Connect() error { panic("RPC Client: the given client is already started. Call Client.Stop() before calling Client.Start() again!") } - if c.rwc, err = c.ch.Connect(); nil != err { + if c.conn, err = c.ch.Connect(); nil != err { return err } c.stopChan = make(chan struct{}) @@ -187,7 +187,7 @@ func (c *client) handleRPC() { <-writerDone } - c.rwc.Close() + c.conn.Close() if err != nil { //c.LogError("%s", err) @@ -258,7 +258,7 @@ func (c *client) rpcWriter(stopChan <-chan struct{}, writerDone chan<- error) { releaseCallState(cs) } - if err = c.ch.GetCodec().Write(c.rwc, cs.Method, cs.Args, cs.ID); nil != err { + if err = c.ch.GetCodec().Write(c.conn, cs.Method, cs.Args, cs.ID); nil != err { err = fmt.Errorf("Client: Cannot send request to wire: [%s]", err) return } @@ -277,7 +277,7 @@ func (c *client) rpcReader(readerDone chan<- error) { }() for { - crn, err := c.ch.GetCodec().NewResponseOrNotify(c.rwc) + crn, err := c.ch.GetCodec().NewResponseOrNotify(c.conn) if nil != err { err = fmt.Errorf("Client: Cannot decode response or notify: [%s]", err) return diff --git a/client/client_handler.go b/client/client_handler.go index d510812..c2b8c58 100644 --- a/client/client_handler.go +++ b/client/client_handler.go @@ -1,7 +1,7 @@ package client import ( - "io" + "net" "time" "git.loafle.net/commons_go/rpc" @@ -9,7 +9,7 @@ import ( ) type ClientHandler interface { - Connect() (io.ReadWriteCloser, error) + Connect() (net.Conn, error) GetCodec() protocol.ClientCodec GetRPCRegistry() rpc.Registry diff --git a/client/client_handlers.go b/client/client_handlers.go index cf46657..997cdf8 100644 --- a/client/client_handlers.go +++ b/client/client_handlers.go @@ -2,7 +2,7 @@ package client import ( "errors" - "io" + "net" "sync" "time" @@ -30,7 +30,7 @@ type ClientHandlers struct { requestIDMtx sync.Mutex } -func (ch *ClientHandlers) Connect() (io.ReadWriteCloser, error) { +func (ch *ClientHandlers) Connect() (net.Conn, error) { return nil, errors.New("RPC Client: ClientHandlers method[Connect] is not implement") }